I have a game where a character is jumping onto moving platforms. The platforms are “bouncy” so the character should bounce off them when he lands on one.
Everything works well UNLESS the character falls down onto a platform that is also moving down - then the character sticks to the platform until it stops, then it seems to receive a large impulse force.
Sample code shown below, if you change the “animated” variable on line 6 from true to false, you will see the bounce works.
Is this a bug or am I doing something wrong??
[lua]local physics = require( “physics” )
physics.start()
local world = display.newGroup()
local moveY=0
local animated=true
local ei=display.newRect( world, 0, 0, 20, 100 )
ei:setFillColor(0,255,0)
ei.x=display.contentWidth/2
ei.y=display.contentHeight/2-200
physics.addBody( ei, { bounce=1, friction=0.1 } )
ei.isFixedRotation = true
local platform=display.newRect( world, 0, 0, 100, 20 )
platform:setFillColor(255,0,0)
physics.addBody( platform,“static”, { bounce=1, friction=0.1 } )
platform.x=display.contentWidth/2
platform.y=display.contentHeight/2
function mainloop()
if (animated and moveY<100) then
platform.y=platform.y+1
moveY=moveY+1
end
end
Runtime:addEventListener(“enterFrame”, mainloop)
[import]uid: 73098 topic_id: 12321 reply_id: 312321[/import]