my d-pad

my d-pad works but I want it so that my button will keep the player in the air while you are pressing it because when I press it the player go’s up but then comes down. I want it like in jet pack joyride where when you are holding the button the player stays in the air.

Corona touch events do not continuously fire.  You get a single “began” phase to let you know the press started, and a single “ended” phase to let you know when they have let up.  You may get “moved” phases in between if the person is moving their finger around.

What you have to do is to set a flag in the began phase saying it’s pressed, then clear the flag when the ended phase comes in.  Then you either use some type of timer to add force to your object, or use a Runtime “enterFrame” event handler that will constantly add velocity to your object ever time the screen updates (1/30th or 1/60th of a second depending on your app’s settings).

That enterFrame listener function would check to see if your flag is set, if it is, apply velocity, if not take it away.

Hope that helps

Rob

Corona touch events do not continuously fire.  You get a single “began” phase to let you know the press started, and a single “ended” phase to let you know when they have let up.  You may get “moved” phases in between if the person is moving their finger around.

What you have to do is to set a flag in the began phase saying it’s pressed, then clear the flag when the ended phase comes in.  Then you either use some type of timer to add force to your object, or use a Runtime “enterFrame” event handler that will constantly add velocity to your object ever time the screen updates (1/30th or 1/60th of a second depending on your app’s settings).

That enterFrame listener function would check to see if your flag is set, if it is, apply velocity, if not take it away.

Hope that helps

Rob