iosenumssprite-kitspritezposition

Organizing zPosition values in Sprite Kit with enums


We have been using enums to organize the zPositions of our sprites. As we started to add SKNodes with several subsprites to our game, the structure quickly began to break down. Some child sprites that were placed on the screen had to have negative values in order to be beneath other nodes with children. These negative values are hard to keep track of in relation to other sprites in separate enums.

Is there a better way to organize the zPosition of sprites (especially those with sub-sprites) than using enums?


Solution

  • Upon reading more into your issue, it looks like you are using multiple enums to organize your z order. I suggest using a single enum for the z - ordering of your game.