I want to make a Temporary Joint for swinging on a chain rope and on the Space bar's release its supposed to delete the Joint and drop the player.
But instead the entire program crashes and the debugger says this on the stack:
I got a small byte of code here for you guys to help solve this.
The collision and the segment of the the Chain rope is found with a Collision Listener.
I'm sure there is a better way to do all the code here but I'v tried so much here and I keep Modifying the code to the point where I don't care about what it looks like.
Using Box2D version 2.2.1 if this helps even a little bit... In case there is a version I'm not aware of.
Oh and Hello to everyone... First post here.
But instead the entire program crashes and the debugger says this on the stack:
Code:
#0 BAADF00D ?? () (??:??)
#1 004156DB b2Joint::Destroy(b2Joint*, b2BlockAllocator*) () (??:??)
#2 0040B7E3 b2World::DestroyJoint(b2Joint*) () (??:??)
#3 004042C7 Player::Update(this=0x2768a0) (C:\Mine\Project Red\Player.cpp:283)
#4 0040274C _fu0___ZN2sf5Color5BlackE() (C:\Mine\Project Red\Game.cpp:130)
#5 00402AC0 Game::OnInit(this=0x28fefc) (C:\Mine\Project Red\Game.cpp:182)
#6 004020B4 Game::Game(this=0x28fefc) (C:\Mine\Project Red\Game.cpp:38)
#7 0040364A main(argc=1, argv=0xb334d0) (C:\Mine\Project Red\Main.cpp:6)
#1 004156DB b2Joint::Destroy(b2Joint*, b2BlockAllocator*) () (??:??)
#2 0040B7E3 b2World::DestroyJoint(b2Joint*) () (??:??)
#3 004042C7 Player::Update(this=0x2768a0) (C:\Mine\Project Red\Player.cpp:283)
#4 0040274C _fu0___ZN2sf5Color5BlackE() (C:\Mine\Project Red\Game.cpp:130)
#5 00402AC0 Game::OnInit(this=0x28fefc) (C:\Mine\Project Red\Game.cpp:182)
#6 004020B4 Game::Game(this=0x28fefc) (C:\Mine\Project Red\Game.cpp:38)
#7 0040364A main(argc=1, argv=0xb334d0) (C:\Mine\Project Red\Main.cpp:6)
I got a small byte of code here for you guys to help solve this.
Code:
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Space) && RopePTR != NULL)
{
b2RevoluteJointDef jd;
jd.collideConnected = false;
b2Vec2 anchor(m_body->GetWorldCenter().x, m_body->GetWorldCenter().y);
jd.Initialize(m_body, RopePTR, anchor);
Joint = (b2RevoluteJoint*)m_body->GetWorld()->CreateJoint(&jd);
}
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Space) == false && GrabbingRope == true)
{
GrabbingRope = false;
m_body->GetWorld()->DestroyJoint((b2RevoluteJoint*)Joint);
}
{
b2RevoluteJointDef jd;
jd.collideConnected = false;
b2Vec2 anchor(m_body->GetWorldCenter().x, m_body->GetWorldCenter().y);
jd.Initialize(m_body, RopePTR, anchor);
Joint = (b2RevoluteJoint*)m_body->GetWorld()->CreateJoint(&jd);
}
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Space) == false && GrabbingRope == true)
{
GrabbingRope = false;
m_body->GetWorld()->DestroyJoint((b2RevoluteJoint*)Joint);
}
The collision and the segment of the the Chain rope is found with a Collision Listener.
I'm sure there is a better way to do all the code here but I'v tried so much here and I keep Modifying the code to the point where I don't care about what it looks like.
Using Box2D version 2.2.1 if this helps even a little bit... In case there is a version I'm not aware of.
Oh and Hello to everyone... First post here.