Cocos2d iphone 如何在cocos2d android中从父级移除精灵
Cocos2d android游戏中的主题: 为了在与另一个精灵碰撞后删除该精灵,我使用了spriteRect函数,但这并不能使该精灵在intersect之后被删除,因为很多Google都知道它应该从父级删除, 这是密码Cocos2d iphone 如何在cocos2d android中从父级移除精灵,cocos2d-iphone,ccsprite,removechild,cocos2d-android,Cocos2d Iphone,Ccsprite,Removechild,Cocos2d Android,Cocos2d android游戏中的主题: 为了在与另一个精灵碰撞后删除该精灵,我使用了spriteRect函数,但这并不能使该精灵在intersect之后被删除,因为很多Google都知道它应该从父级删除, 这是密码 CGRect ship1Rect = CGRect.make(ship1.getPosition().x - (ship1.getContentSize().width/2), ship1.getPosition()
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)代码>在这一行中,错误是“家长无法解决”错误,我哪里出错了?有人能告诉我吗
ship1.getParent().removeChild(ship1,true);
或
您只能使用
removeChild(ship1,真实);
代替
removeChildByTag(17,真)
ship1.getParent(). removeChildByTag(17,true);