In my android game I'm trying to spawn a projectile that flies across the screen and has an animation using 4 .png files. However whenever a projectile spawns it crashes the entire app. Here's my code:
protected void addProjectile() {
CCSprite projectile = CCSprite.sprite("projectile1.png");
CCAnimation projectileAnimation = CCAnimation.animation("", 0.1f);
for (int i = 1; i <= 4; i++) {
projectileAnimation.addFrame(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName("projectile" + i + ".png"));
}
CCAction projectileAction = CCAnimate.action(1, projectileAnimation, true);
projectile.setPosition(CGPoint.ccp(winSize.width + (projectile.getContentSize().width / 2.0f), winSize.height / 2));
addChild(projectile);
projectile.setTag(1);
_projectiles.add(projectile);
int minDuration = 3;
int maxDuration = 6;
int rangeDuration = maxDuration - minDuration;
int actualDuration = rand.nextInt(rangeDuration) + minDuration;
CCMoveTo actionMove = CCMoveTo.action(actualDuration, CGPoint.ccp(-projectile.getContentSize().width / 2.0f + 320, winSize.height / 2));
CCCallFuncN actionMoveDone = CCCallFuncN.action(this, "spriteMoveFinished");
CCSequence actions = CCSequence.actions(actionMove, actionMoveDone);
projectile.runAction(actions);
projectile.runAction(projectileAction);
}
Any help would be appreciated.