目前我制作的一款游戏有一个问题,我想问一下有没有解决方案。基本上,我的游戏完美地加载到主菜单,没有任何问题,就像任何其他应用程序一样快,但当我按下播放按钮,这将把你带到MainGameScene,它需要大约3-4秒,该场景才会出现。它只在您第一次按下播放按钮时出现。因此,如果你死了,回到主菜单并再次点击播放,它会立即加载。所以我的问题是,为什么加载MainGameScene需要几秒钟的时间?是不是我在编码时遗漏了什么?不是预加载吗?-(空)loadTextures{
我刚刚试过了,但场景不会从加载屏幕过渡到主菜单场景。有什么想法吗?
NSMutableArray *imageArray = [[NSMutableArray alloc] initWithObjects:@"obstacle.png","background.png","Ghost.png", nil];
[SKTexture preloadTextures:imageArray withCompletionHandler:^
{
SKTransition *reveal = [SKTransition fadeWithDuration:0.75];
MGLCreateMainMenuScene *scene = [[MGLCreateMainMenuScene alloc] initWithSize:self.view.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
[self.view presentScene:scene transition:reveal];
}];}
发布于 2014-04-03 20:16:35
您的预加载代码不正确。请尝试执行以下操作:
NSMutableArray *imageArray = [[NSMutableArray alloc] init];
[imageArray addObject: [SKTexture textureWithImageNamed:@"obstacle.png"]];
[imageArray addObject: [SKTexture textureWithImageNamed:@"background.png"]];
[imageArray addObject: [SKTexture textureWithImageNamed:@"Ghost.png"]];
[SKTexture preloadTextures:imageArray withCompletionHandler:^
{
SKTransition *reveal = [SKTransition fadeWithDuration:0.75];
MGLCreateMainMenuScene *scene = [[MGLCreateMainMenuScene alloc] initWithSize:self.view.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
[self.view presentScene:scene transition:reveal];
}];https://stackoverflow.com/questions/22775670
复制相似问题