I'm very new to Gideros and I have looked around for this answer but I'm getting a little frustrated.
I'm starting off very basic.
Id like to move a sprite with the arrow keys on the keyboard.
and after you release to key the sprite still moves a little in that direction.
I have no idea how to do this.
Ive looked in the reference and I think I somehow merge these 2 codes?
function onMouseDown(event)
print(event.x, event.y) <--- but a translate function?
end
mysprite:addEventListener(Event.MOUSE_DOWN, onMouseDown)
with
stage:addEventListener(Event.KEY_DOWN, function(event)
if event.keyCode == KeyCode.BACK then
application:exit() <----- with translate function?
end
end)
Then I think another event for when I let go of the key?
If anyone could help me Id greatly appreciate this.
Joe
Comments
There's probably a bunch of examples in these forums... but there are basically two ways.
The first way is to use box2d if you require sprites to interact and collide with each other. Box2d at first can be a bit overwhelming, but extremely valuable once you get the hang of it.
The second is something like this (using my example above):
you are aware that not all mobile devices would have and respond to the arrow keys.
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
if keypressed then sprite:setX(sprite:getX()+1) end.
Same deal for MOUSE_DOWN, MOUSE_UP.
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975