Last active
August 29, 2015 14:00
-
-
Save veeneck/11143583 to your computer and use it in GitHub Desktop.
zPosition World Layers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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