Hi!
-
How can i jump through platform? in event we got contact.isEnabled but this work cool when we go only up.
-
When i jump on platform in physic debug mode my object have gray color and don’t fall down when platform end.
local physics = require(“physics”) physics.start() physics.setGravity( 0, 20 ) physics.setDrawMode(“hybrid”) _W = display.contentWidth/2; _H = display.contentHeight/2; local isGrounded = true; local currentGround = 0; local player = display.newRect( _W, _H +175, 100,100 ) physics.addBody( player, “dynamic” , { density=3.0, friction=10.0, bounce=0.0 }) player.isFixedRotation = true; player.angularVelocity = 0 player.x = _W; player.y = _H+175; player.name = “player”; function onObjectTouch( event ) if event.phase == “ended” then if (isGrounded == true) then player:applyLinearImpulse( 0, -800, player.x, player.y ); end end end local tailsX = -128; function firstTails() for i = 1, 14 do local tail = display.newRect( 0, 0, 128,128 ) tail:setFillColor(0,1,0); tail.x = tailsX + 128 tail.y = _H * 2; tailsX = tail.x; tail.name = “ground”; physics.addBody( tail, “static”, { density=100.0, friction=10.0, bounce=0.0 } ) end local flyBegan = display.newRect( 0, 0, 128,128 ) flyBegan:setFillColor(0,1,0); firstX = _W + 800 flyBegan.x = firstX flyBegan.y = _H + 70 ; flyBegan.name = “ground”; transition.to( flyBegan, { time=5500, x=(-2000 +firstX) } ) physics.addBody( flyBegan, “static”, { density=100.0, friction=10.0, bounce=0.0 } ) for i = 1, 2 do local tail = display.newRect( 0, 0, 128,128 ) tail:setFillColor(0,1,0); tail.x = firstX + 128 tail.y = _H + 70; firstX = tail.x; tail.name = “ground”; physics.addBody( tail, “static”, { density=100.0, friction=10.0, bounce=0.0 } ) transition.to( tail, { time=5500, x=(-2000 +firstX) } ) end local flyEnd = display.newRect( 0, 0, 128,128 ) flyEnd:setFillColor(0,1,0); flyEnd.x = firstX + 128 flyEnd.y = _H + 70 ; flyEnd.name = “ground”; transition.to( flyEnd, { time=5750, x=(-2000 +firstX) } ) physics.addBody( flyEnd, “static”, { density=100.0, friction=10.0, bounce=0.0 } ) end firstTails() local function onCollision( event ) local obj = event.object1; local obj2 = event.object2; event.contact.isEnabled = false; if ( event.phase == “began” ) then if(obj.name == “player” and obj2.name == “ground”) then isGrounded = true; end elseif ( event.phase == “ended” ) then if(obj.name == “player” and obj2.name == “ground”) then isGrounded = false; end end end Runtime:addEventListener( “touch”, onObjectTouch ) Runtime:addEventListener( “collision”, onCollision )