PhysicsBody::~PhysicsBody() { CC_SAFE_DELETE(_info); removeAllShapes(); for (auto it = _joints.begin(); it != _joints.end(); ++it) { PhysicsJoint* joint = *it; PhysicsBody* other = joint->getBodyA() == this ? joint->getBodyA() : joint->getBodyB(); other->_joints.erase(std::find(other->_joints.begin(), other->_joints.end(), joint)); delete joint; } }
void BoySprite::changeShape(){ if(this->getPhysicsBody() == nullptr){ return; } auto body = this->getPhysicsBody(); body->removeAllShapes(); if(this->getCurrentState() == ACTION_STATE_RUN) { body->addShape(NORMAL_SHAPE); }else if(this->getCurrentState() == ACTION_STATE_SLIDE){ body->addShape(SLIDE_SHAPE); }else if(this->getCurrentState() == ACTION_STATE_JUMP_UP){ body->addShape(NORMAL_SHAPE); }else if(this->getCurrentState() == ACTION_STATE_JUMP_DOWN){ body->addShape(NORMAL_SHAPE); } }
CustomGraphicsScene::~CustomGraphicsScene() { removeAllShapes(); }