2014-08-30 69 views
0

我要让主人公的动画,当他跳到SpriteKit动画错误

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' 

回答

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]; 
+0

非常感谢! – clear 2014-08-30 17:31:44