Hi!
I’m trying to implement elastic rope as in this game: http://www.physicsgames.net/game/Gen.html to be able to control many circles to make it get round difficulties. Game uses Box2D too.
I’ve wrote this code:
[lua]local physics = require( “physics” )
physics.start()
physics.setGravity(0, 0)
physics.setScale( 30 )
–physics.setDrawMode(“debug”)
rootJoint = display.newImageRect(“bacteria.png”, 20, 20)
rootJoint.x = 160
rootJoint.y = 600
physics.addBody( rootJoint, “kinematic” )
colony = display.newImageRect(“generator_colony.png”, 80, 80)
colony.x = 160
colony.y = 400
physics.addBody( colony, “static”, { density=3.0, friction = 0, bounce=0, radius = 40 } )
bacterias = {}
for i = 1, 40 do
bacterias[i] = display.newImageRect(“bacteria.png”, 20, 20)
bacterias[i].x = 160 + math.random(-30, 30)
bacterias[i].y = 750 + math.random(-30, 30)
bacterias[i].isFixedRotation = true
physics.addBody( bacterias[i], { density=1.0, friction = 0, bounce=0, radius = 10 } )
local dist = physics.newJoint( “distance”, bacterias[i], rootJoint, bacterias[i].x, bacterias[i].y, rootJoint.x, rootJoint.y )
end
transition.to(rootJoint, {time = 5000, x = 160, y = 0})[/lua]
I use rootJoint to control all others. I translate it thought big sircle so small can get round it.
But there is a problem: some circles just stuck at big circle and don’t want to get round it or do this too slowly. Friction is 0.
How can I do same effect as in that game?
Help please. [import]uid: 94357 topic_id: 16524 reply_id: 316524[/import]
[import]uid: 3826 topic_id: 16524 reply_id: 61749[/import]