Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help,
read this.
-
Zae
- Prole
- Posts: 3
- Joined: Wed Feb 25, 2009 3:54 am
Post
by Zae »
Hi every one, i'm new to programming at all, and to LOVE in particular. i've got code
Code: Select all
function keypressed(...)
if key ~= love.key_space and fire == 0 then
love.audio.play( pew )
fire = 0.01
table.insert(bullets, {x = x, y = y-15})
end
the function work when any key pressed, i need it to work when "space" key pressed, what must i do?
Thanks.
-
Kaze
- Party member
- Posts: 189
- Joined: Sat Jul 19, 2008 4:39 pm
- Location: Dublin, Ireland
Post
by Kaze »
function keypressed(...)
should be:
function keypressed( key )
-
zapwow
- Prole
- Posts: 48
- Joined: Fri Oct 24, 2008 11:37 pm
Post
by zapwow »
You have:
Code: Select all
if key ~= love.key_space and fire == 0 then
Let's take a closer look:
closer...
This means "is not equal". You want "is equal", like you have "fire == 0"
Code: Select all
if key == love.key_space and fire == 0 then
-
Zae
- Prole
- Posts: 3
- Joined: Wed Feb 25, 2009 3:54 am
Post
by Zae »
Thanks very much guys, it works.
Users browsing this forum: Bing [Bot] and 1 guest