在这个cocos2d-android游戏中,如果两个精灵(船和目标)相交的船应该消失,这是如何我给了代码,但不能删除相交后的精灵,我搜索了谷歌,但没有帮助我,这是代码在cocos2d-iphone“_targets removeObject:雪碧;”,但找不到任何类似的cocos2d-android,请任何人知道这帮助我。
if (CGRect.intersects(targetRect, shipRect))
{
System.out.println("ship deleted: " + ship);
this.removeChild(ship, true);
}发布于 2013-06-12 00:25:31
你想稍后移走这些船,而不是在这个IF中,对吧?
因此,您需要将ship添加到一个数组中,然后循环此数组,并使用removeFromParent方法删除所有ship。
sprite cocos2d-iphone代码sprite removeObject:_targets是从数组中移除对象的代码;
https://stackoverflow.com/questions/17037216
复制相似问题