--\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* -- drawButtons() --\> --\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* local flyPlane = function(event) if event.phase == "began" and gameIsActive == true then print("began") physics.setGravity( 0, -10 ) elseif event.phase == "ended" and gameIsActive == true then print("ended") physics.setGravity( 0, 7 ) inBound = true elseif event.phase == "moved" and gameIsActive == true then -- do nothing end end --\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* -- keepPlaneInBound() --\> --\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* local keepPlaneInBound = function() -- print("checking") if paperPlane.y \<= paperPlane.height + 10 and gameIsActive == true and inBound == true then inBound = false paperPlane.y = paperPlane.height + 12 end end
The function flyPlane is set on “touch” “enterframe” eventlistner and keepPlaneInBound has been set to “Runtime” “enterframe” eventlistner. What i want ot achieve is that when the plane exceeds the upper bound limit. Its previous physcis.setGravity value to be completely removed and the new value to be assigned to it when the user lifts the finger (when event = “ended”).
What happens odd is that it does not accept the new physics.setGravity() value. In case i use physics.pause() and then assign it the new geavity value. On physics.start it first completes the part of the previous setGravity value hence moving it upwards again… 