-2

これを試して:

  1. SKEffectNode クラスを作成する
  2. 8 フレーム程度の小さなアニメーションを作成し、atlas フォルダーに入れます。
  3. このコードをクラスの初期化に追加します

初期クラス

-(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;

}

このノードをシーンに追加します。結果は何もレンダリングされません。まだ効果を有効にしていないことに注意してください。

なぜ?

4

1 に答える 1