Hi,
I am running with physics and having an object with a Pivot joint that I am releasing. I am then trying to add some force to the object, but nothing happens? Do I have to add a delay? Why doesn't the force affect my object?
1 2 3 4 | myPivot:removeSelf() myPivot = nil myObj:applyForce(0,-420,myObj.x,myObj.y) |
I just ran this test code quickly (very cobbled together obviously) and it worked fine.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | require ( "physics" ) physics.start() physics.setGravity( 0, 0 ) physics.setDrawMode ( "hybrid" ) myObj = display.newCircle( 160, 60, 20 ) physics.addBody(myObj) myObj2 = display.newCircle( 160, 300, 20 ) physics.addBody(myObj2) myPivot = physics.newJoint( "pivot", myObj, myObj2, 200,300 ) myObj:applyForce(0,-4,myObj.x,myObj.y) |
Hi Peach,
Try the following code without the removal of the join, then try it with that code and you will notice the diffrence.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | require ( "physics" ) physics.start() physics.setGravity( 0, 18 ) physics.setDrawMode ( "hybrid" ) myObj = display.newCircle( 160, 60, 20 ) physics.addBody(myObj,"static") myObj2 = display.newCircle( 160, 300, 20 ) physics.addBody(myObj2,"dynamic",{radius = 24, density = 0.1, friction = 0.1, bounce = .1}) myPivot = physics.newJoint( "pivot", myObj, myObj2, 200,300 ) myPivot:removeSelf() --Try with and without and see the difference myObj2:applyForce(210,-144,myObj2.x,myObj2.y) |
I am running 704 :)
I mean, try with the join created and directly removed. And then try without the joint ever created. In both cases the behavior would be the same?
views:1401 update:2012/1/1 13:29:50