Issues with batch drawing with atlas files and SpriteKit

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:

  • iOS change navigation bar title font and color
  • Can't create externalDataReference interim file
  • iPhone/iPad: Unable to copy folder from NSBundle to NSDocumentDirectory
  • Will iCloud sync the files in Document folder of all apps?
  • Instruments: Leaks and Allocations (tvOS)
  • Objective c, Memory management of instance members
  • 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!!!

    Solutions Collect From Internet About “Issues with batch drawing with atlas files and SpriteKit”

    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.