-2

Try this:

  1. Create a SKEffectNode class
  2. Create a small animation, 8 frames or so, put them into an atlas folder
  3. add this code to the class init

INIT CLASS

-(id)init {

  self = [super init];

  if (self) {

    SKTextureAtlas *atlas = [SKTextureAtlas atlasNamed:@"shield.atlas"];

    NSMutableArray *images=[NSMutableArray arrayWithCapacity:8];
    for (int i=1; i<=8; i++) {
      NSString *fileName=[NSString stringWithFormat:@"shield%d.png",i];
      SKTexture *tempTexture=[atlas textureNamed:fileName];
      [images addObject:tempTexture];
    }

    NSUInteger numberOfFrames = [images count];

    SKAction *animate = [SKAction animateWithTextures:images timePerFrame:1.0f/numberOfFrames resize:YES restore:NO];
    SKAction *forever = [SKAction repeatActionForever:animate];
    [self runAction:forever];

  }

  return self;

}

Add this node to your scene. The result is nothing is rendered. Notice that I am not even enabling the effects yet.

why?

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
Duck
  • 34,902
  • 47
  • 248
  • 470

1 Answers1

3

SKEffectNode is not a SKSpriteNode, so you cannot utilize SKSpriteNode's methods. What you can do is create a SKSpriteNode property that utilizes your animation and add that as a child of your SKEffectNode.

prototypical
  • 6,731
  • 3
  • 24
  • 34