當我不使用紋理地圖集時,一切正常。但是當我使用紋理地圖集時,animateWithTextures不起作用,也不會顯示任何內容。 這裏是我的代碼SpriteKit 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];
你看這裏:http://stackoverflow.com/questions/19159537/ios-spritekit-animation-does-not-appear和這裏http://www.raywenderlich.com/45152/sprite-kit-tutorial -animations-and-texture-atlases – DogCoffee
@Smick謝謝,我在那找到答案。 –