trouble with keyreleased( key )

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.
Post Reply
Zae
Prole
Posts: 3
Joined: Wed Feb 25, 2009 3:54 am

trouble with keyreleased( key )

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.
User avatar
Kaze
Party member
Posts: 189
Joined: Sat Jul 19, 2008 4:39 pm
Location: Dublin, Ireland

Re: trouble with keyreleased( key )

Post by Kaze »

function keypressed(...)
should be:
function keypressed( key )
User avatar
zapwow
Prole
Posts: 48
Joined: Fri Oct 24, 2008 11:37 pm

Re: trouble with keyreleased( key )

Post by zapwow »

You have:

Code: Select all

if key ~= love.key_space and fire == 0 then
Let's take a closer look:
  • if key ~= love.key_space

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

Re: trouble with keyreleased( key )

Post by Zae »

Thanks very much guys, it works.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest