event.phase hold.

Hey guys.

I got a jet when you touch the screen it will go up. When you ended it will go down again. And when you move it will also go down. But now i see when you hold your finger on the screen without moving your finger, it will keep going up. Any1 knows how to fix that?

Code:

function jetUp(self,event)

    self:applyForce(0, -2, self.x, self.y)

end

function jetMove(event)

    if event.phase == “began” then

            jet.enterFrame = jetUp

            Runtime:addEventListener(“enterFrame”, jet)

    end

    if event.phase == “moved” then

         Runtime:removeEventListener(“enterFrame”, jet)

    end

    if event.phase == “ended” then

            Runtime:removeEventListener(“enterFrame”, jet)

    end

end

That code was written so that the jet keeps rising until you lift off your finger. If you just want the jet to move up once you could try:

function jetMove(event) if event.phase == "began" then jet:applyForce(0, -100, jet.x, jet.y) end end

… or something like this. You don’t need an enterFrame event if you only want the jet to move up on the initial screen touch

That code was written so that the jet keeps rising until you lift off your finger. If you just want the jet to move up once you could try:

function jetMove(event) if event.phase == "began" then jet:applyForce(0, -100, jet.x, jet.y) end end

… or something like this. You don’t need an enterFrame event if you only want the jet to move up on the initial screen touch