Issues with batch drawing with atlas files and SpriteKit

北城余情 提交于 2019-12-24 08:41:33

问题


So I ran into a problem with lag on a platformer game I'm building. So I'm researching how to improve performance.

I'm trying to do batch drawing, so that there is less draw calls. I'm having issues though. So with a brand new project:

I have 4 hero sprites, all images are stored in a .atlas folder. so there is a 1/2/3x image for each sprite in the atlas folder.

I drag and drop that into the xcassets folder. Then I go to my sks file create 4 sprites and change the texture accordingly.

By default they all have the same blend mode. I have the default rule set to true for ignoring sibling order. All sprites are on the default z 0 layer. and I have it set to show draw count.

I would expect to see 1 draw since all images are in the same atlas file, but I see 4.

Is there something I'm missing?

Just curious how I get this to work properly. Thanks for any help!!!


回答1:


There was a bug with xcassets on iOS 9 where draw calls wouldn't be reduced even if images were placed in xcassets. Apparently that was fixed with later versions, but since then I never bothered with xcassets. Instead I place images in a seperate .atlas folder in the project, which does reduce the draw calls.

Try to place 4 sprites with the same texture and see what the draw calls are then. It shouldn't be 4 if the sprites are using the same texture. I would also suggest to add 8 sprites (4 different textures * 2 sprites each) and see if the draw calls increase to 8.

If the draw calls don't increase, then I would assume that 4 draw calls is what it takes to draw your 4 different sprites (if they are very complex ones). If the draw calls do increase, try removing the images from xcassets and place them into a seperate .atlas folder in your project, and compare draw calls then.



来源:https://stackoverflow.com/questions/44479805/issues-with-batch-drawing-with-atlas-files-and-spritekit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!