SpriteKit animateWithTextures不适用于纹理图集

Han*_*gbo 5 cocoa-touch objective-c ios ios7 sprite-kit

当我不使用纹理图集时,一切都运行正常.但是当我使用纹理图集时,animateWithTextures不起作用而且什么都没有出现.这是我的代码

SKTexture *spaceshipTexture = [SKTexture textureWithImageNamed:@"monkey.png"];
SKSpriteNode *spaceship = [SKSpriteNode spriteNodeWithTexture:spaceshipTexture];
spaceship.position = CGPointMake(0,0);
spaceship.anchorPoint = CGPointMake(0,0);
[self addChild: spaceship];

NSMutableArray *images=[NSMutableArray arrayWithCapacity:14];
for (int i=1; i<=14; i++) {
    NSString *fileName=[NSString stringWithFormat:@"%dShuGuangx.png",i];
    SKTexture *tempTexture=[SKTexture textureWithImageNamed:fileName];
    [images addObject:tempTexture];
}
NSLog(@"count %d",images.count);
SKAction *walkAnimation = [SKAction animateWithTextures:images timePerFrame:0.1];
[spaceship runAction:walkAnimation];
Run Code Online (Sandbox Code Playgroud)

Han*_*gbo 6

[SKTexture preloadTextures:images withCompletionHandler:^(void){
        [spaceship runAction:walkAnimation];
    }];
Run Code Online (Sandbox Code Playgroud)

这解决了我的问题.