当前位置: 首页>>代码示例>>C++>>正文


C++ PhysicsBody::removeFromWorld方法代码示例

本文整理汇总了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);

}
开发者ID:rickystone,项目名称:Match2,代码行数:14,代码来源:Attack.cpp

示例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;
}
开发者ID:silviomazzotta,项目名称:Pippo,代码行数:86,代码来源:GameSceneQuattro.cpp


注:本文中的PhysicsBody::removeFromWorld方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。