试试这个:
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;
}
将此节点添加到场景中。结果是没有渲染。请注意,我甚至没有启用效果。
为什么?
答案 0 :(得分:3)
SKEffectNode
不是SKSpriteNode
,因此您无法使用SKSpriteNode
的方法。您可以做的是创建一个SKSpriteNode
属性,该属性利用您的动画并将其添加为SKEffectNode
的孩子。