Hi everyone, I am stuck on this problem. I’m trying make a platformer game and am having trouble making the character move.
I am applying force in the direction I want with a button, but it only happens every time I press it, but I want it to happen as long as the button is being pressed.
Here is the code I have so far for the button (I am just going to post the code for my left button as I am sure you get what I mean from it)
[code] local function buttonLeftTouch(event)
local phase = event.phase
if “began” == phase then
hero:applyForce(-0.2, 0, hero.x, hero.y)
buttonLeft.height=72
buttonLeft.width=72
end
local phase = event.phase
if “ended” == phase then
hero:applyForce(0, 0, hero.x, hero.y)
buttonLeft.height=64
buttonLeft.width=64
end
return true
end
buttonLeft:addEventListener(“touch”, buttonLeftTouch)[/code]
Any help would be greatly appreciated!
Kevin [import]uid: 2752 topic_id: 7522 reply_id: 307522[/import]