0
votes

The bellow code is not repeating inspite of explicitly setting the SKAction as repeatActionForever.

SKAction *action = [SKAction moveToY:self.frame.size.height + bullet.size.height duration:2];
SKAction *remove = [SKAction removeFromParent];
SKAction *fireForever = [SKAction repeatActionForever:[SKAction sequence:@[action,remove]]];
[bullet runAction:fireForever];

The bullet just fires once , when its expected to be fired every 1 second.

1
You are removing the bullet node from parent and not creating a new one. - sangony

1 Answers

0
votes

You are removing the bullet from the parent, that's why it's not firing again, What you should do is create a method to create a bullet - fire it - destroy it, and create an SKAction that uses this method.

-(void)FireBullet
{
    //create bullet
    //fire it
    //remove from parent
}

and add the following code when you want the bullets to start firing.

SKAction *myAction = [SKAction performSelector:@selector(FireBullet) onTarget:self];
SKAction *forever = [SKAction repeatActionForever:myAction];
[self runAction:forever];

Hope this helps, let me know if you need more help.