![]()
这是我的代码
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];解决方法 [SKTexture preloadTextures:images withCompletionHandler:^(voID){ [spaceship runAction:walkAnimation]; }]; 这解决了我的问题.
总结以上是内存溢出为你收集整理的ios – SpriteKit animateWithTextures不适用于纹理图集全部内容,希望文章能够帮你解决ios – SpriteKit animateWithTextures不适用于纹理图集所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)