Hi!
I have an object that is supposed to move up (applyForce) when I touch the screen and continue to move up when I hold down the screen. And when touch ended the applyForce will stop.
This is what I’ve come up with:
function moveShooter(event)
if ( event.phase == "began" ) then
shooter:applyForce( 0, -2, shooter.x, shooter.y )
elseif ( event.phase == "moved" ) then
Runtime:addEventListener("enterFrame", moveShooter2)
elseif ( event.phase == "ended" ) then
shooter:applyForce( 0, 0, shooter.x, shooter.y )
end
end
function moveShooter2(event)
shooter:applyForce( 0, -0.05, shooter.x, shooter.y )
end
background:addEventListener("touch", moveShooter)
If I press and just hold it just move up once, then go down (by gravity). But if I move around when holding down, the object goes up and disappears from display. What I want is that if I press and hold the object moves up until I stop holding, then it goes down.
How should I do this?
Best regards,
joelwe [import]uid: 54640 topic_id: 9715 reply_id: 309715[/import]

[import]uid: 51516 topic_id: 9715 reply_id: 35398[/import]