在我的 cocos2d-android 游戏项目中,随机数量的目标从顶部表面落到船上,当两个相交的船都应该被删除时,我已经完成了编码,但“船”没有被删除。CGRect sprite 不会被删除吗?有人知道吗?
LinkedList<CCSprite> targetsToDelete = new LinkedList<CCSprite>();
for (CCSprite target : _targets)
{
CGRect targetRect = CGRect.make(target.getPosition().x - (target.getContentSize().width),
target.getPosition().y - (target.getContentSize().height),
target.getContentSize().width,
target.getContentSize().height);
CCSprite ship = CCSprite.sprite("ship150.png");
ship.setPosition(CGPoint.ccp(30,200));
ship.setAnchorPoint(CGPoint.ccp(0,0));
ship.setTag(25);
addChild(ship);
// ship.setVisible(false);
CGRect shipRect = CGRect.make(ship.getPosition().x - (ship.getContentSize().width/2),
ship.getPosition().y - (ship.getContentSize().height/2),
ship.getContentSize().width,
ship.getContentSize().height);
System.out.println("ships to delete continue... : " + volume);
if (CGRect.intersects(targetRect, shipRect))
{
System.out.println("ships intersected:)@@@@@@@@@@@@@@@@@@@@@@@@@@@@@... : " + volume);
removeChildByTag(25, false);
}
}