KeyConstant

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
poorenglish
Prole
Posts: 47
Joined: Thu Sep 24, 2009 1:49 pm

KeyConstant

Post by poorenglish » Sat Dec 26, 2009 2:00 pm

In the documents,the 0.6.0 version's KeyConstant is less than 0.50?
I find some keys are missing ,such F1 to F12,Alt,Ctrl,Shift,left,right,up,down,and so on
I try the F1,F4, find the key is useful,I think the document for 0.60 should update
the link is http://love2d.org/docs/KeyConstant.html

User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: KeyConstant

Post by Robin » Sat Dec 26, 2009 2:05 pm

Oh, I'm sorry. I wrote that, as a test, but forgot to update it.
F1 is 'f1' etc.
the left alt key is 'lalt' etc.
the right alt key is 'ralt' etc.
the arrow keys are 'left', 'right', 'up', 'down'
See this for a complete conversion table.
Help us help you: attach a .love.

User avatar
Garotas*Gostosas
Prole
Posts: 41
Joined: Fri Apr 03, 2009 12:15 am

Re: KeyConstant

Post by Garotas*Gostosas » Thu Dec 31, 2009 1:10 am

is there a bug with the key constants in 0.6.0 or is it just me?
when you press "up" arrow it does "down" arrow and vice versa. :cry:
left and right are inverted, too. check my .love out
i'm on a macbook with 10.5
arrow.love
see source, then play
(26.27 KiB) Downloaded 169 times
PS: happy new year everybody!
I LOVE GAME, YEAH!

User avatar
bmelts
Party member
Posts: 380
Joined: Fri Jan 30, 2009 3:16 am
Location: Wiscönsin
Contact:

Re: KeyConstant

Post by bmelts » Thu Dec 31, 2009 4:33 am

In your source, you have this:

Code: Select all

function love.keypressed(k,u)

	if k ~= "up" then		 
		up = true
	end
	-- repeat for all the directions, in love.keyreleased too
That's saying that if the key that was pressed is not up, to set up to true. Thus, when someone presses the up arrow key, right, left, and down all get set to true -- but not up.

Right and left cancel each other out in the update phase in terms of movement, so all you see is the ball moving down, but in reality, it's moving every direction except up.

Change all those ~= to == and everything ought to function properly.

User avatar
Garotas*Gostosas
Prole
Posts: 41
Joined: Fri Apr 03, 2009 12:15 am

Re: KeyConstant

Post by Garotas*Gostosas » Thu Dec 31, 2009 12:00 pm

oops! :oops: tanks anjo, you're the man!
I LOVE GAME, YEAH!

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests