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 ) runnerTransition = transition.to( obj, { y=jumpTo, time=runnerTrasistionTime} ); runnerRotation = transition.to( obj, { rotation = 0,--[[rotation=obj.rotation + 90, --]]time=runnerTrasistionTime } ) end function RunnerJump(self, event) if (((self.y \<= ground + 1) and (self.y\>= ground - 1)) or ((self.y \<= firstFloor + 101) and(self.y\>= firstFloor - 99))) then runnerTransition = transition.to( self, { y=self.y - jumpHeight, time=runnerTrasistionTime} ); runnerRotation = transition.to( self, { rotation = 0,--[[rotation=self.rotation + 90, --]]time=runnerTrasistionTime, onComplete=RunnerDown } ) end end
on preCollision i set my jumpTo:
local function preCollision( event ) left = event.object1; right = event.object2; if((left.myName == "runner") and (right.myName == "floor")) then jumpTo = right.y - right.height; isGoDown = 1; end end