3
我在我的節點上有幾幀動畫,並且第一次播放它滯後的動畫,fps下降。每次下一次都很好,很棒。如何預先加載Sprite套件中的紋理?
如何預加載紋理以使其工作流暢?
我有這樣的方法來運行,當我加載遊戲:
- (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"]];
}
而且此方法播放動畫:
-(void)playExplosionAnimation
{
self.size = CGSizeMake(250, 250);
SKAction *animation = [SKAction animateWithTextures:self.animationFrames timePerFrame:0.1];
[self runAction:animation completion:^{
self.hidden = YES;
}];
}
當預加載紋理圖譜時,雖然我在樂器中驗證了此工作是在工作線程上完成的,但我正在經歷fps下降。我也嘗試過,並將其封裝在全局調度隊列的'async'塊中,這沒有幫助。你有什麼想法可能會造成這種情況? – damirstuhec