Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 我应该使用什么方法预加载精灵?_Ios_Sprite Kit_Skspritenode - Fatal编程技术网

Ios 我应该使用什么方法预加载精灵?

Ios 我应该使用什么方法预加载精灵?,ios,sprite-kit,skspritenode,Ios,Sprite Kit,Skspritenode,我知道你可以通过在游戏开始时创建spritenodes来预加载spritenodes,但是有没有更有效的方法呢 请参阅上的章节 创建SKTexture而不是SkSpritode。 然后您可以使用乙醚或类方法 处理预加载的一个好方法是使用纹理地图集。通过使用纹理图集,可以将所有纹理组合到一个包含所有纹理的较大“表”中。这允许精灵套件只创建一个纹理对象加载到VRAM中。因为它只显示精灵表的一部分,所以atlas中的所有纹理都可以通过GPU的每个过程绘制到屏幕上 下面是我如何使用preloadWith

我知道你可以通过在游戏开始时创建spritenodes来预加载spritenodes,但是有没有更有效的方法呢

请参阅上的章节

创建SKTexture而不是SkSpritode。 然后您可以使用乙醚或类方法

处理预加载的一个好方法是使用纹理地图集。通过使用纹理图集,可以将所有纹理组合到一个包含所有纹理的较大“表”中。这允许精灵套件只创建一个纹理对象加载到VRAM中。因为它只显示精灵表的一部分,所以atlas中的所有纹理都可以通过GPU的每个过程绘制到屏幕上

下面是我如何使用preloadWithCompletionHandler:方法预加载纹理:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{

//  Preload the textures
self.artAtlas = [SKTextureAtlas atlasNamed:@"art"];
[self.artAtlas preloadWithCompletionHandler:^{
//  Textures loaded so we are good to go!

    /* Pick a size for the scene
     Start with the current main display size.
     */
    NSInteger width = [[NSScreen mainScreen] frame].size.width;
    NSInteger height = [[NSScreen mainScreen] frame].size.height;
    JRWTitleScene *scene = [JRWTitleScene sceneWithSize:CGSizeMake(width, height)];

    /* Set the scale mode to scale to fit the window */
    scene.scaleMode = SKSceneScaleModeAspectFit;

    [self.skView presentScene:scene];
}];

#if DEBUG
self.skView.showsFPS = YES;
self.skView.showsNodeCount = YES;
#endif

}

有关预加载纹理的更多信息,请参阅的相关章节。

请参阅

创建SKTexture而不是SkSpritode。 然后您可以使用乙醚或类方法

处理预加载的一个好方法是使用纹理地图集。通过使用纹理图集,可以将所有纹理组合到一个包含所有纹理的较大“表”中。这允许精灵套件只创建一个纹理对象加载到VRAM中。因为它只显示精灵表的一部分,所以atlas中的所有纹理都可以通过GPU的每个过程绘制到屏幕上

下面是我如何使用preloadWithCompletionHandler:方法预加载纹理:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{

//  Preload the textures
self.artAtlas = [SKTextureAtlas atlasNamed:@"art"];
[self.artAtlas preloadWithCompletionHandler:^{
//  Textures loaded so we are good to go!

    /* Pick a size for the scene
     Start with the current main display size.
     */
    NSInteger width = [[NSScreen mainScreen] frame].size.width;
    NSInteger height = [[NSScreen mainScreen] frame].size.height;
    JRWTitleScene *scene = [JRWTitleScene sceneWithSize:CGSizeMake(width, height)];

    /* Set the scale mode to scale to fit the window */
    scene.scaleMode = SKSceneScaleModeAspectFit;

    [self.skView presentScene:scene];
}];

#if DEBUG
self.skView.showsFPS = YES;
self.skView.showsNodeCount = YES;
#endif

}

有关预加载纹理的更多信息,请参阅相关章节。

您使用的是什么,sprite kit还是cocos2d iphone?请使用相应的标签。您使用的是什么,sprite套件还是cocos2d iphone?请使用相应的标签。我制作了一个image.atlas文件夹,并将其设置在xcode中,以便我的所有图像仍能正常工作。现在游戏中的skspritenodes是从.atlas文件夹中的图像生成的。如何以及在何处创建SKTextureAtlas以及NSMutableArray?我想在游戏打开时进行预加载。我制作了一个image.atlas文件夹,并将其设置在xcode中,这样我所有的图像都可以正常工作。现在游戏中的skspritenodes是从.atlas文件夹中的图像生成的。如何以及在何处创建SKTextureAtlas以及NSMutableArray?我想做我的预加载权利时,游戏打开。