【发布时间】:2014-02-08 00:15:57
【问题描述】:
我的初始视图控制器中有这段代码,在函数 viewWillLayoutSubviews 中:
SKTextureAtlas *obstacleAtlas = [SKTextureAtlas atlasNamed:@"gonImages"];
obstacleAtlas = [SKTextureAtlas atlasNamed:@"gonImages"];
SKTexture *castle = [obstacleAtlas textureNamed:@"castle@2x.png"];
SKTexture *column = [obstacleAtlas textureNamed:@"columnNE@2x.png"];
SKTexture *factory = [obstacleAtlas textureNamed:@"factory@2x.png"];
SKTexture *hotAirBallon = [obstacleAtlas textureNamed:@"hotAirBallon@2x.png"];
SKTexture *lightningBolt = [obstacleAtlas textureNamed:@"lightningBolt@2x.png"];
SKTexture *pirateShip = [obstacleAtlas textureNamed:@"pirateShip@2x.png"];
SKTexture *pyramidNE = [obstacleAtlas textureNamed:@"PyramidNE@2x.png"];
SKTexture *rocket = [obstacleAtlas textureNamed:@"rocket@2x.png"];
SKTexture *sun = [obstacleAtlas textureNamed:@"sun@2x.png"];
SKTexture *wheel = [obstacleAtlas textureNamed:@"wheel@2x.png"];
NSArray *obstacleTextures = @[castle, column, factory, hotAirBallon, lightningBolt, pirateShip, pyramidNE, rocket, sun, wheel];
[SKTexture preloadTextures:obstacleTextures withCompletionHandler:^{
// Present the scene.
[skView presentScene:startScene];
//[skView presentScene:scene];
}];
我想在我的游戏开始之前加载这些纹理,这样我在游戏过程中就不会出现延迟。然而,这似乎不起作用,因为每当从我的障碍图集中找到的图像制作新的精灵节点时,游戏就会滞后。我是否正确预加载?如果没有,我应该如何以及在哪里这样做。
【问题讨论】:
标签: xcode sprite-kit preloading