SpriteKit动画错误

时间:2014-08-30 17:04:33

标签: ios animation sprite-kit

我想在跳跃时让英雄成为动画

 NSArray *animatedImages = [NSArray arrayWithObjects:
                                   [UIImage imageNamed:@"hero_1.png"],
                                   [UIImage imageNamed:@"hero_2.png"],
                                   [UIImage imageNamed:@"hero_1.png"],
                                   [UIImage imageNamed:@"hero_.png"], nil];
    SKAction *jump = [SKAction animateWithTextures:animatedImages timePerFrame:0.2];
    [hero runAction:jump];

此代码位于didBeginContact

错误

-[UIImage isRotated]: unrecognized selector sent to instance

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImage isRotated]: unrecognized selector sent to instance 0x1780945a0'

1 个答案:

答案 0 :(得分:2)

您无法为UIImage对象制作动画,它们必须是SKTexture对象。

NSArray *animatedImages = [NSArray arrayWithObjects:
                               [SKTexture textureWithImageNamed:@"hero_1.png"],
                               [SKTexture textureWithImageNamed:@"hero_2.png"],
                               [SKTexture textureWithImageNamed:@"hero_1.png"],
                               [SKTexture textureWithImageNamed:@"hero_.png"], nil];