在Cocos2d-android游戏中的主题:为了删除与另一个精灵相撞后的精灵,我使用了spriteRect函数,但这并不是让精灵在相交后被删除,在很多谷歌之后知道它应该从父母中删除,这是代码
CGRect ship1Rect = CGRect.make(ship1.getPosition().x - (ship1.getContentSize().width/2),
ship1.getPosition().y - (ship1.getContentSize().height/2),
ship1.getContentSize().width,
ship1.getContentSize().height);
if (CGRect.intersects(targetRect, ship1Rect))
{
parent.removeChildByTag(17, true);
}但是在这里,这行中的parent.removeChildByTag(17, true);得到的错误是"parent cannot be resolved“错误,我哪里出错了,有人能告诉我吗
发布于 2013-06-27 17:05:37
ship1.getParent().removeChild(ship1,true);或
ship1.getParent(). removeChildByTag(17,true);发布于 2014-01-03 15:12:09
您只能使用removeChild(ship1,true);而不能使用parent.removeChildByTag(17,true);
https://stackoverflow.com/questions/17338554
复制相似问题