Skip to content

Instantly share code, notes, and snippets.

@veeneck
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save veeneck/11143583 to your computer and use it in GitHub Desktop.
Save veeneck/11143583 to your computer and use it in GitHub Desktop.
zPosition World Layers
/* The layers in a scene. */
typedef enum : uint8_t {
WorldLayerGround = 0,
WorldLayerBelowCharacter,
WorldLayerCharacter,
WorldLayerAboveCharacter,
WorldLayerTop,
kWorldLayerCount
} WorldLayer;
/* Later in the scene initialization */
_layers = [NSMutableArray arrayWithCapacity:kWorldLayerCount];
for (int i = 0; i < kWorldLayerCount; i++) {
SKNode *layer = [[SKNode alloc] init];
layer.zPosition = i - kWorldLayerCount;
[_world addChild:layer];
[(NSMutableArray *)_layers addObject:layer];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment