Hey guys,
I have few platforms (circles objects) on the screen, and those platforms are moving around.
Also, I have my hero, who can jump from one platform to another, once the jump has finished, meaning the hero has “landed” safely on the platform, I would like to fix its position to the platform while its moving.
Im trying to use joints, but I’m probably doing this wrong…
[lua]
local physics = require( “physics” )
physics.start()
physics.setGravity( 0, 0 )
local myJoint
[/lua]
here is how I declare a platform:
[lua] local platform = display.newCircle( 0, 0, 80 )
physics.addBody( platform, { friction=0, bounce=0, density=0, radius=platform.radius,filter = {maskBits = 2, categoryBits = 2}} )[/lua]
And my hero:
[lua]
local hero = display.newCircle( 0, 0, 30 )
physics.addBody( hero, { friction=0, bounce=0, density=0, radius=hero.radius, filter = {maskBits = 1, categoryBits = 1}} )
[/lua]
Now upon tapping the platform I’m making this:
[lua]
function platform:touch(e)
if (e.phase == “began”) then
myJoint = physics.newJoint( “pivot”, hero, platform, platform.x,platform.y )
end
end
platform:addEventListener(“touch” , platform)
[/lua]
And it doesn’t work… obviously…
Any help would be greatly appreciated
Roy.