Dvo*_*ole 3 textures ios sprite-kit
我的节点上有几帧动画,第一次播放动画时它会滞后,fps下降.每次下次都很好,花花公子.
如何预加载纹理以使其工作顺畅?
我加载游戏时运行此方法:
- (void)load
{
self.animationFrames = @[[SKTexture textureWithImageNamed:@"exp1"], [SKTexture textureWithImageNamed:@"exp2"],
[SKTexture textureWithImageNamed:@"exp3"], [SKTexture textureWithImageNamed:@"exp4"], [SKTexture textureWithImageNamed:@"exp5"], [SKTexture textureWithImageNamed:@"exp6"], [SKTexture textureWithImageNamed:@"exp7"], [SKTexture textureWithImageNamed:@"exp8"], [SKTexture textureWithImageNamed:@"exp9"]];
}
Run Code Online (Sandbox Code Playgroud)
而这种播放动画的方法:
-(void)playExplosionAnimation
{
self.size = CGSizeMake(250, 250);
SKAction *animation = [SKAction animateWithTextures:self.animationFrames timePerFrame:0.1];
[self runAction:animation completion:^{
self.hidden = YES;
}];
}
Run Code Online (Sandbox Code Playgroud)
Raf*_*fAl 10
你应该创建一个纹理图集并使用SKTextureAtlas方法:
– preloadWithCompletionHandler:
+ preloadTextureAtlases:withCompletionHandler:
Run Code Online (Sandbox Code Playgroud)
以下是文档中对此的说明:
Sprite Kit创建一个后台任务,用于从地图集加载纹理数据.然后,Sprite Kit将控制权返回给您的游戏.加载纹理图集后,将调用完成处理程序.
如果需要一次预加载多个纹理图集,请改用该
preloadTextureAtlases:withCompletionHandler:方法.
| 归档时间: |
|
| 查看次数: |
2685 次 |
| 最近记录: |