使用spritekit在单个图形中渲染节点? [英] Render nodes in single drawing pass with spritekit?

查看:106
本文介绍了使用spritekit在单个图形中渲染节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我四处寻找有关spritekit纹理的信息时,我偶然发现了这句话:

As I was looking around for information about spritekit textures, and I stumbled upon this quote:


如果a的所有子元素节点使用相同的混合模式和纹理图集,则Sprite Kit通常可以在一次绘制过程中绘制这些Sprite。另一方面,如果将子级组织起来,以便每个新精灵都改变绘图模式,则Sprite Kit可能会作为每个精灵一次绘图传递,这是非常低效的。

If all of the children of a node use the same blend mode and texture atlas, then Sprite Kit can usually draw these sprites in a single drawing pass. On the other hand, if the children are organized so that the drawing mode changes for each new sprite, then Sprite Kit might perform as one drawing pass per sprite, which is quite inefficient.

但请检查以下内容:

具有相同纹理的瓦片(我向您保证它是纹理,而不仅仅是颜色)

Tiles with same texture (I assure you it's a texture, not just a color)

具有自己纹理的瓷砖

Tiles with their own texture

抽奖次数尽管使用的所有纹理都来自同一图集,但相差40。

The draw count has a difference of 40, although all of the textures used came from the same atlas.

我将 atlas一词解释为错误吗?

Am I interpreting the word 'atlas' wrong?

这是我存储图像的地方:

This is where I store my images:

我的示例是纹理地图集,还是地图集的定义,这里是包含所有需要的图像和个人双重切片是切成薄片的吗?

Is my example a 'texture atlas,' or is the definition of 'atlas' here a single .png that contains all the images needed, and individual tiles are sliced from it?

或者问题可能出在我如何加载/其他东西上?

Or is the problem probably in how I am loading/something else?

谢谢!

推荐答案

这里的问题很可能是由于节点图本身造成的。假设您有100个精灵作为场景的子级,而没有自己的子级子级,并且它们都使用相同图集和默认混合模式下的纹理,则Sprite Kit将在一次绘制调用中批量绘制这100个子级。

The problem here is most likely because of the node graph itself. Say you have 100 sprites as children of the scene, with not sub-children of their own, and they all use textures from the same atlas and default blend modes, then Sprite Kit will batch-draw these 100 sprites in a single draw call.

但是,如果这些磁贴精灵具有自己的子代(可能是形状或标签节点)用于调试,则将中断批处理绘图操作。

However if these tile sprites have children of their own, perhaps shape or label nodes for debugging, then this will "interrupt" the batch drawing operation.

检查节点图。确保所有图块精灵都是同一父级的子级,并且没有自己的子级,并使用来自相同图集的相同混合模式和纹理。

Check your node graph. Make sure all tile sprites are children of the same parent, and have no children of their own, use the same blend modes and textures from the same atlas. Then batch drawing will definitely work.

如果这不起作用,请验证tile.atlas文件夹是否正确转换为捆绑包中的纹理图集。如果您打开已编译的应用程序捆绑包,则应该找到一个名为 tiles.atlasc的文件夹,其中包含一个plist和一个或多个png文件,其中包含该文件夹的所有单个图片。此外,这些单独的图像都不应该出现在捆绑软件中-如果使用与地图集中相同的名称将它们作为单独的文件添加到捆绑软件中,则Sprite Kit将默认加载单个图像文件,而不是从纹理地图集中获取它们

If that doesn't work, verify that the tiles.atlas folder is correctly converted to a texture atlas in the bundle. If you open the compiled app bundle you should find a folder named 'tiles.atlasc' with a plist and one or more png files in it, containing all individual images of the folder. Furthermore none of these individual images should appear in the bundle - if they are added to the bundle as individual files using the same names as in the atlas, then Sprite Kit will default to loading the individual image files rather than obtaining them from the texture atlas.

这篇关于使用spritekit在单个图形中渲染节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆