尝试这个:
- 创建一个 SKEffectNode 类
- 制作一个小动画,8帧左右,放入atlas文件夹
- 将此代码添加到类初始化
初始化类
-(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;
}
将此节点添加到您的场景中。结果是什么都没有渲染。请注意,我什至还没有启用效果。
为什么?