I just started working on an idea for a game and am just testing things out to see what works.
I have a character and all I want is to be able to use left and right arrow images I have on screen and to move the character while these images are being touched.
Here is my code, It is not working so I know this is not the proper way of doing it, any suggestions to accomplish moving the character with the arrow buttons would be appreciated.
--get hero on screen and place him by the ground image local hero= display.newImage("images/hero.png") hero.y=ground.y local function moveHero(event) if event.phase == "began" then while event.phase == "began" do transition.to(hero,{time=500, x=hero.x + 5}) end arrowButton:addEventListener("touch", moveHero())
My logic was supposed to be if the button is pressed move the guy from where he is 5pixels and keep moving him 5 pixels while its pressed.
Thats not happening.
Whats the proper way?