本文整理汇总了C++中PhysicsBody::removeFromWorld方法的典型用法代码示例。如果您正苦于以下问题:C++ PhysicsBody::removeFromWorld方法的具体用法?C++ PhysicsBody::removeFromWorld怎么用?C++ PhysicsBody::removeFromWorld使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhysicsBody
的用法示例。
在下文中一共展示了PhysicsBody::removeFromWorld方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fuckxx
void Attack::fuckxx(Sprite* xx)
{
PhysicsBody* body = xx->getPhysicsBody();
body->removeFromWorld();
auto rotate = RotateBy::create(4.0, 360);
auto repeat = RepeatForever::create(rotate);
auto moveby = MoveBy::create(1.0f, Point(0,-30));
xx->runAction(repeat);
xx->runAction(moveby);
}
示例2: onContactBegin
bool GameSceneQuattro::onContactBegin(cocos2d::PhysicsContact &contact)
{
cocos2d::log("GameSceneQuattro::onContactBegin ....... inizio ");
PhysicsBody *a = contact.getShapeA()->getBody();
PhysicsBody *b = contact.getShapeB()->getBody();
PhysicsBody *pallinaBody = nullptr ;
if ( ! (3 == a->getCollisionBitmask() && 3 == b->getCollisionBitmask())){
if ( 3 == a->getCollisionBitmask() )
{
// CCLOG( "GameSceneQuattro::onContactBegin COLLISION HAS OCCURED" );
pallinaBody = contact.getShapeA()->getBody();
}
if ( 3 == b->getCollisionBitmask() )
{
pallinaBody = contact.getShapeB()->getBody();
}
if(pallinaBody){
_emitter->setPosition(pallinaBody->getNode()->getPosition());
_emitter->resetSystem();
_emitter->setDuration(0.5);
//prendo tag
if (12 == pallinaBody->getTag()){
cocos2d::log("GameSceneQuattro::onContactBegin colpita pallina 2 ");
//deve variare la y
// pallinaBody->applyForce( Vect(-50, -220) );
pallinaBody->setVelocity(Vec2(randomValueTra(900,900),
randomValueTra(0,500)));
}
if (13 == pallinaBody->getTag()){
cocos2d::log("GameSceneQuattro::onContactBegin colpita pallina 3 ");
pallinaBody->setVelocity(Vec2(randomValueTra(900,1900),
randomValueTra(0,800)));
}
if (14 == pallinaBody->getTag()){
cocos2d::log("GameSceneQuattro::onContactBegin colpita pallina 4 ");
pallinaBody->setVelocity(Vec2(randomValueTra(900,1900),
randomValueTra(0,800)));
}
if (15 == pallinaBody->getTag()){
cocos2d::log("GameSceneQuattro::onContactBegin colpita pallina 5 ");
pallinaBody->setVelocity(Vec2(randomValueTra(900,1900),
randomValueTra(-400,800)));
}
}
}
if (PIETRA_TAG == a->getTag()){
// cocos2d::log("GameSceneQuattro::onContactBegin ....... 1 ");
a-> getNode()->stopAllActions();
a-> getNode()->setVisible(false);
a->removeFromWorld();
//a->setEnable(false); // a->applyForce( Vect(100, 78) );
}
if (PIETRA_TAG == b->getTag() ){
// cocos2d::log("GameSceneQuattro::onContactBegin ....... 2 ");
b-> getNode()->stopAllActions();
b-> getNode()->setVisible(false);
b->removeFromWorld();
// b->setEnable(false);
// b->applyForce( Vect(100, 78) );
}
CCLOG("Forse megio cosi recupero i tag e poi faccio tutto" );
auto sp = (Sprite*)contact.getShapeA()->getBody()->getNode();
int tag = sp->getTag();
CCLOG("onContactBegin tag di A : %d", tag);
auto spb = (Sprite*)contact.getShapeA()->getBody()->getNode();
int tagb = spb->getTag();
CCLOG("onContactBegin tag di B : %d", tagb);
return true;
}