0

我有一个使用以下代码在屏幕上显示动画的对象:

    CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFrames("ninjastar.plist");
    CCSpriteSheet projectileSheet = CCSpriteSheet.spriteSheet("ninjastar.png");
    addChild(projectileSheet);
    ArrayList<CCSpriteFrame> projectileSprites = new ArrayList<CCSpriteFrame>();

    for (int i = 1; i <= 4; i++) {
        projectileSprites.add(CCSpriteFrameCache.spriteFrameByName("ninjastar" + i + ".png"));
    }

    CCAnimation projectileAnimation = CCAnimation.animation("throw", 0.1f, projectileSprites);
    CCSprite projectile = CCSprite.sprite(projectileSprites.get(0));
    CCAction projectileAction = CCRepeatForever.action(CCAnimate.action(projectileAnimation, false));
    projectile.setPosition(CGPoint.ccp(winSize.width + (projectile.getContentSize().width / 2.0f), actualY));
        actionMove = CCMoveTo.action(actualDuration, CGPoint.ccp(-projectile.getContentSize().width / 2.0f + 320, actualY));
projectileSheet.addChild(projectile);
    projectile.setTag(1);
    _projectiles.add(projectile);
    CCCallFuncN actionMoveDone = CCCallFuncN.action(this, "spriteMoveFinished");
    CCSequence actions = CCSequence.actions(actionMove, actionMoveDone);
    projectile.runAction(actions);
    projectile.runAction(projectileAction);

我正在使用“spriteMoveFinished”来删除精灵,一旦它完成穿过屏幕:

public void spriteMoveFinished(Object sender) {
    CCSprite sprite = (CCSprite)sender;
    _projectiles.remove(sprite);
    sprite.stopAllActions();
    removeChild(sprite, true);
}

然而,当精灵到达屏幕的末端时,它只是停留在最后一帧。如何完全删除它?

4

0 回答 0