2013-06-25 2 views
0

내 cocos2d-android 게임 프로젝트에서 목표물의 무작위 수가 우주선의 상면에서 낙하하여 교차 할 때 우주선이 모두 삭제되어야합니다. 그러나 "우주선"은 아닙니다. 삭제 중. CGRect 스프라이트가 삭제되지 않는다는 것입니까? 아무도 이걸 압니까?CGRect sprites 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); 

    } 

} 
+0

은 _targets의 모든 타겟에 새로운 브랜드의 'ship'을 추가 한 것입니까? – Kreiri

+0

답장을 보내 주셔서 감사합니다. 하나의 우주선과 여러 대상이 있습니다. @Kreiri –

+0

은 parent.removeChild (node, true)와 같은 것입니다. 부여해야합니까? @Kreiri –

답변

0

코드는 업데이트 루프에 당신이 당신의 루프에 배를 추가하는이 방법은 모든 time.Its은 실제로 당신이 효과를 볼되지 않을 수 있습니다 삭제. 당신의 우주선을 당신의 업데이트 코드 밖으로 추가하는 코드를 꺼내서 초기화 코드에 넣고 우주선 스프라이트를 전역으로 만든 다음 교차점을 확인하십시오.