Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an object going across the screen with an animation using the following code:

CCSpriteSheet projectileSheet = CCSpriteSheet.spriteSheet("ninjastar.png");
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));
CCCallFuncN actionMoveDone = CCCallFuncN.action(this, "spriteMoveFinished");
CCSequence actions = CCSequence.actions(actionMove, actionMoveDone);

I'm using "spriteMoveFinished" to remove the sprite once it is done going across the screen:

public void spriteMoveFinished(Object sender) {
CCSprite sprite = (CCSprite)sender;
removeChild(sprite, true);

However, when the sprite gets to the end of the screen it just stays stuck there on the last frame. How do I remove it completely?

share|improve this question
up vote 1 down vote accepted

The projectile is added to projectileSheet, but being removed from current layer or scene, rather than removing from projectileSheet. The last line of spriteMoveFinished should be

projectileSheet.removeChild(sprite, true);

or better use

share|improve this answer
Thank you very much that works! – Frozsht May 15 '13 at 3:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.