Jumping and falling to other object

Hi!

i Create some jumping

local ground 400; local jumpHeight = 150; local RunnerDown = function( obj )     runnerTransition = transition.to( obj, { y=self.y + jumpHeight, time=runnerTrasistionTime} );     runnerRotation = transition.to( obj, { rotation=obj.rotation  + 90, time=runnerTrasistionTime } ) end function RunnerJump(self, event)         runnerTransition = transition.to( self, { y=self.y - jumpHeight, time=runnerTrasistionTime} );         runnerRotation = transition.to( self, { rotation=self.rotation  + 90, time=runnerTrasistionTime, onComplete=RunnerDown } ) end local runner = display.newRect( 0, ground, 100, 100 ); runner:setFillColor( 1, 0, 0 ); runner.myName = "runner"; physics.addBody(runner, { bounce = 0.2 }); runner.touch = RunnerJump;

but my object allways go to my start point, i want runner stay on some kind of floor. Any solutions or hints?

If you want to use physics then don’t use transitions to move it butobject:applyForce().

You need a floor which has a physics body as well so you don’t fall off the screen.

Then if you want to jump on ledge that ledge has to have a physics body also not just the runner.

Check the physics API docs for more.

:slight_smile: i try apply force many time, but i want some animation, i will try preCollision :slight_smile:

You can use transitions for animation (like the rotation you are doing in code) but don’t use transitions to move the runner.

If you want to use physics then don’t use transitions to move it butobject:applyForce().

You need a floor which has a physics body as well so you don’t fall off the screen.

Then if you want to jump on ledge that ledge has to have a physics body also not just the runner.

Check the physics API docs for more.

:slight_smile: i try apply force many time, but i want some animation, i will try preCollision :slight_smile:

You can use transitions for animation (like the rotation you are doing in code) but don’t use transitions to move the runner.