Hi all. I am new here. I try to combine two examples Ebook template and example project under Hardware -- "Keyboard"
I just copy the code from Hardware/Keyboard example into sceneController.lua. So when I try to print out any message erevything is ok
function onKeyDown(event)
if event.keyCode == KeyCode.LEFT then
print("menu Button Down")
end
end
But when when I try to move, for example self.left button the APPLICATION՝ player, terminated (closed)
function onKeyUp(event)
if event.keyCode == KeyCode.LEFT then
print ("menu Button Up")
self.left:setPosition(100, 100)
end
end
Please help me to understand what is wrong, seems I cant do anything with other objects on the stage
Comments
The addEventListener function allows you to pass in additional data however, so you can do something like this:
Don't forget that lua files are processed from up to down. If you are trying to alter some vaiable out of scope it will raise error. Like before init of a class, trying to use self.left
Try putting these eventlisteners inside sceneController:init method
at this time it isn't recognized events, I mean even not print messages
You can try to put them one by one if player crashes