我将纹理图集拖到我的项目中。图片命名正确(“heliani_1-9”) 动画运行流畅,除了3帧,在白地上显示为大红色十字。(见附件截图)
我的代码有什么问题?
干杯
#import "MRMPlayer.h"
@implementation MRMPlayer
-(instancetype)init
{
self = [super init];
{
[self setupAnimations];
[self runAction:[SKAction repeatActionForever:[SKAction animateWithTextures:self.runFrames timePerFrame:0.5 resize:YES restore:NO]] withKey:@"heli"];
self.name = playerName;
}
return self;
}
-(void) setupAnimations{
self.runFrames = [[NSMutableArray alloc]init];
SKTextureAtlas *heliAtlas = [SKTextureAtlas atlasNamed:@"heli"];
for (int i = 0; i < [heliAtlas.textureNames count]; i++) {
NSString *tempName = [NSString stringWithFormat:@"heliani_%d",i];
SKTexture *tempTexture = [heliAtlas textureNamed:tempName];
if(tempTexture) {
[self.runFrames addObject:tempTexture];
}
}
}
@end