Work with assets - Use texture atlases to improve performance

 

使用资源 - 使用纹理地图集来提高性能...

我只知道 好像

认真的男人最美丽

会不会一直演下去

到他们满意

A texture atlas improves performance of your apps by combining multiple image assets into a larger image file. Then your app can draw multiple images with a single draw call.

文本地图集通过合并多个图像集到一个大大图像文件来提高你应用程序的性能。然后你的应用程序可以调用一个单独的画来画多个图像。

The compiler looks for folders with a

.atlas
file extension in your project and combines the containing images into one or more texture atlases. The images are rotated and trimmed to fit the maximum number of images into each texture atlas. The maximum size of a texture atlas image is 2048 x 2048 or 4098 x 4098 pixels, depending on your project’s texture atlas options. If a texture atlas image reaches the maximum size, the compiler creates a new texture atlas.

编译器在文件夹中查找.atlas后缀名的文件并编译包含一个或多个纹理地图集的图像。图像旋转和修剪到每个纹理地图集图像的最大尺寸。纹理地图集图像的最大尺寸是2048*2048或者4098*4098像素,依据你的项目文本纹理地图集选项。如果纹理地图集图像达到最大尺寸,编译器创建新的纹理地图集。

The following image shows four image files combined into a single texture atlas.

下面图像显示了四个图像文件合并到一个纹理地图集。
In the app bundle’s Resource folder, a texture atlas is represented by a folder with a
.atlasc
file extension. The texture atlas images and their orientation are tracked by an associated property list. The SpriteKit framework knows how to access your images through the property list and therefore, no code changes are required.

在应用程序包资源文件夹,纹理地图集通过文件夹中后缀名为.atlasc的文件进行呈现。纹理地图集图像和它的方向通过管理属性列表进行跟踪。SpriteKit框架通过属性列表知道如何访问你的图像。因此,不需要代码的改变。

If your project doesn’t use the SpriteKit framework, you can still use texture atlases by including
.atlas
folders in your project and manually reading the generated property list file at runtime.

如果你的工程没有使用SpriteKit框架,你仍然可以通过在项目中包含.atlas文件夹使用纹理地图集并在运行时手动阅读生成的属性列表文件。

Add a texture atlas to your project

增加纹理地图集到你的项目

1. Place the image files you want to add to a texture atlas in a single folder.

1、定位到你想要增加到纹理地图集的图片所在的单独文件夹。

2. Give the folder a .atlas file extension.

2、给文件夹后缀名改为.atlas。

3. Choose File > Add Files to [AppName].

3、选择 文件 > 增加文件到[应用程序名]。

Change the texture atlas options

改变纹理地图集选项

1. In the Project navigator, select your project.

1、在项目导航,选择你的项目。

2. In the editor area, click Build Settings.

2、在编辑区域,点击构建设置。

3. Type
texture
in the search field, and press Return.

3、在搜索栏输入纹理,按下回车键。

The SpriteKit Texture Atlas Options appear.

SpriteKit纹理地图集选项显示。
Important: To view the texture atlas options, you must have a folder with a
.atlas
file extension in your project.

重要:预览纹理地图集选项,你必须有一个以.atlas为后缀名的文件夹在你的项目中。

4. From the Texture Atlas Maximum Size pop-up menu, choose a maximum size.

4、从纹理地图集最大尺寸弹出菜单,选择一个最大尺寸。

SEE ALSO

SKTextureAtlas Class Reference

SpriteKit Framework

SpriteKit Programming Guide
本文英文及图片部分全部出自Apple官方文档

由于水平有限,翻译难免存在不妥之处,请读者指正


    关注 爱上Xcode


微信扫一扫关注公众号

0 个评论

要回复文章请先登录注册