Position of obiect wird behavior

Hi!

There’s my problem:

http://www.youtube.com/watch?v=pSJKk-GNCCk

when i jumping at the beginning of my ‘floor’ my ‘runner’ permeates, but when ‘runner’, this look like my object be in other place but object was rendered on other place.

my runner:

runner = display.newRect( 0, ground, 100, 100 ); runner:setFillColor( 1, 0, 0 ); runner.myName = "runner"; physics.addBody(runner); runner.touch = RunnerJump;

my floor:

    function setFloor(x1, y1, delay, speed)         floors = display.newRect( x1, y1, 500, 50 );         floors:setFillColor( 0, 1, 0 );         floors.myName = "floor";         physics.addBody(floors, "static");         timer.performWithDelay( delay, function()               opponentTimer = transition.to( floors, { time=speed, x=-750, onComplete=removeSelf } )         end, 1 )         end

my check end of floor:

    function checkVariables( event )         if ((runner.x \>= floors.x + floors.width) and isGoDown == 1) then             runnerTransition = transition.to( runner, { y=ground, time=runnerTrasistionTime} );             runnerRotation = transition.to( runner, { rotation =0,time=runnerTrasistionTime, onComplete=resetGoDown  } )         end     end

end my jump for runner

local RunnerDown = function( obj ) &nbsp;&nbsp; &nbsp;runnerTransition = transition.to( obj, { y=jumpTo, time=runnerTrasistionTime} ); &nbsp;&nbsp; &nbsp;runnerRotation = transition.to( obj, { rotation = 0,--[[rotation=obj.rotation&nbsp; + 90, --]]time=runnerTrasistionTime } ) end function RunnerJump(self, event) &nbsp;&nbsp; &nbsp;if (((self.y \<= ground + 1) and (self.y\>= ground - 1)) or ((self.y \<= firstFloor + 101) and(self.y\>= firstFloor - 99))) then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;runnerTransition = transition.to( self, { y=self.y - jumpHeight, time=runnerTrasistionTime} ); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;runnerRotation = transition.to( self, { rotation = 0,--[[rotation=self.rotation&nbsp; + 90, --]]time=runnerTrasistionTime, onComplete=RunnerDown } ) &nbsp;&nbsp; &nbsp;end end

on preCollision i set my jumpTo:

local function preCollision( event ) &nbsp;&nbsp; &nbsp;left = event.object1; &nbsp;&nbsp; &nbsp;right = event.object2; &nbsp;&nbsp; &nbsp;if((left.myName == "runner") and (right.myName ==&nbsp; "floor")) then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;jumpTo = right.y - right.height; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;isGoDown = 1; &nbsp;&nbsp; &nbsp;end end

Transitions are not optimal when using physics.
Since box2D makes all the calculation by itself, the best way is usually to let him do its stuff.
For example, if you want to simulate a “floor” moving towards the player, you can either have the player still and the floor moving towards him (using setLinearVelocity on the floor if it’s not static, or self.x = self.x-floorSpeed in an enterFrame event if otherwise, but this kinda overwrites what box2D is doing), or better, make the player move, and the world stay still.
So you set the linearVelocity of your player, leave the floor static with no movements, and you “follow him” with a camera by doing this in an enterFrame event:
 

player.parent.x = -player.x+display.contentCenterX --change display.contentCenterX to something else to have him followed at another point on the screen

Transitions are not optimal when using physics.
Since box2D makes all the calculation by itself, the best way is usually to let him do its stuff.
For example, if you want to simulate a “floor” moving towards the player, you can either have the player still and the floor moving towards him (using setLinearVelocity on the floor if it’s not static, or self.x = self.x-floorSpeed in an enterFrame event if otherwise, but this kinda overwrites what box2D is doing), or better, make the player move, and the world stay still.
So you set the linearVelocity of your player, leave the floor static with no movements, and you “follow him” with a camera by doing this in an enterFrame event:
 

player.parent.x = -player.x+display.contentCenterX --change display.contentCenterX to something else to have him followed at another point on the screen