I've been having extreme difficulty getting joints to be deleted. I'm making my first (sort-of) box2D game. The player is a ragdoll, and what I'm trying to do right now is give the player the ability to launch his arms on command. Yes, it is funny...
My code is organized into functions, so there's one function that creates a ragdoll at a specified position, and the code for the ragdoll is similar to the testBed ragdoll example. I haven't been able to delete joints from the ragdoll outside of the ragdoll function, however if I enter "m_world.DestroyJoint(jdLArm2);" inside of the createRagDoll function, the joint is destroyed. How can the joint be deleted from outside of the function?
Also, a question I had earlier, but probably posted in the wrong place... :
My code is organized into functions, so there's one function that creates a ragdoll at a specified position, and the code for the ragdoll is similar to the testBed ragdoll example. I haven't been able to delete joints from the ragdoll outside of the ragdoll function, however if I enter "m_world.DestroyJoint(jdLArm2);" inside of the createRagDoll function, the joint is destroyed. How can the joint be deleted from outside of the function?
Also, a question I had earlier, but probably posted in the wrong place... :
recursive wrote:
So... How would you make it so that instead of having the player always at the screen's center, the screen will move with the player only if he moves close to the boundaries? My code almost works, but it's not quite right (the player can't get back to the center of the screen unless he is at the world's center). It's basically this:
(RagDollTorso is the element of the player that is centered, and 450 and 100 are 100 pixels away from the screen's boundaries)
Code:
if(RagDollTorso.GetWorldCenter().x > 450/physScale)
{scrollX = (450/physScale - RagDollTorso.GetWorldCenter().x) * physScale;}
else if(RagDollTorso.GetWorldCenter().x < 100/physScale)
{scrollX = (100/physScale - RagDollTorso.GetWorldCenter().x) * physScale;}
{scrollX = (450/physScale - RagDollTorso.GetWorldCenter().x) * physScale;}
else if(RagDollTorso.GetWorldCenter().x < 100/physScale)
{scrollX = (100/physScale - RagDollTorso.GetWorldCenter().x) * physScale;}
(RagDollTorso is the element of the player that is centered, and 450 and 100 are 100 pixels away from the screen's boundaries)