我是初學者,目前我正在使用cocos2d-x2.2.3在x-code中開發一個類似2048的遊戲。在我的遊戲中,我必須碰撞兩個精靈。碰撞時,我已經卸下兩個spites並添加相同location.I一個新的精靈正在使用下面的代碼:如何刪除精靈並再次使用相同的精靈
if(_player1->boundingBox().intersectsRect(_player2->boundingBox()))
{
this->removeChild(_player1, true);//it is not removing properly
this->removeChild(_player2, true);
_player1 = new CCSprite();
_player1->initWithFile("2.png");
_player1->setPosition(ccp(position.x,position.y));
this->addChild(_player1);//I have to add same player again
}
在此先感謝
感謝您的回覆...... – 2014-09-22 06:24:47