0
在我的cocos2d-的Android游戏项目,目标随机数从顶面落在船上,当两个相交船舶应被删除,我也做了编码,但“船”是不是被删除。 CGRect精灵是不会被删除的?有人知道吗?的CGRect精灵问题在cocos2d-的Android
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);
}
}
是您为_targets中的每个目标添加全新的'ship'船舶吗? – Kreiri
感谢您的回复,只有一艘船和很多目标@Kreiri –
就像是parent.removeChild(node,true);必须得到? @Kreiri –