2014-08-30 83 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