我想把英雄跳起来做成动画
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'
最佳答案
您不能为 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];
关于ios - SpriteKit 动画错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25584837/