Unresponsive Keys

Ask all of your support questions here

Unresponsive Keys

Postby RDSouth » Thu Jan 26, 2012 11:16 am

This works

display:create ( "Supergame", 1280, 640, 32, true )
BallImage = Image ( )
BallImage:load ( "Sprites/Ball.png")
Ball = Sprite (560,0 )
Ball.canvas:set_source_image ( BallImage )
Ball.canvas:paint ( )
display.viewport:add_child ( Ball )
timer = Timer ( )
timer:start ( 32, true )
timer.on_tick = function ( timer )
if keyboard:is_down ( KEY_UP ) then
Ball.y=Ball.y+8
end
if keyboard:is_down ( KEY_RIGHT ) then
Ball.x=Ball.x-8
end
if keyboard:is_down ( KEY_DOWN ) then
Ball.y=Ball.y-8
end
if keyboard:is_down ( KEY_LEFT ) then
Ball.x=Ball.x+8
end
end

This doesn't.

display:create ( "Supergame", 1280, 640, 32, true )
BallImage = Image ( )
BallImage:load ( "Sprites/Ball.png")
Ball = Sprite (560,0 )
Ball.canvas:set_source_image ( BallImage )
Ball.canvas:paint ( )
display.viewport:add_child ( Ball )
timer = Timer ( )
timer:start ( 32, true )
timer.on_tick = function ( timer )
if keyboard:is_down ( KEY_W ) then
Ball.y=Ball.y+8
end
if keyboard:is_down ( KEY_D ) then
Ball.x=Ball.x-8
end
if keyboard:is_down ( KEY_S ) then
Ball.y=Ball.y-8
end
if keyboard:is_down ( KEY_A ) then
Ball.x=Ball.x+8
end
end
RDSouth
 
Posts: 5
Joined: Mon Jan 23, 2012 7:26 am

Re: Unresponsive Keys

Postby Ivan » Thu Jan 26, 2012 3:12 pm

Hi.
Both examples work on my machine.
Are you saying that "keyboard:is_down ( KEY_W )" always returns false?
Ivan
Site Admin
 
Posts: 414
Joined: Thu Dec 27, 2007 9:21 pm


Return to Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron