Game Development Reference
In-Depth Information
-(GameLayer*) gameLayer
{
CCNode* layer = [self getChildByTag:LayerTagGameLayer];
NSAssert([layer isKindOfClass:[GameLayer class]], @"%@: not a GameLayer!", ←
NSStringFromSelector(_cmd));
return (GameLayer*)layer;
}
-(UserInterfaceLayer*) uiLayer
{
CCNode* layer = [[MultiLayerScene sharedLayer] getChildByTag:LayerTagUILayer];
NSAssert([layer isKindOfClass:[UserInterfaceLayer class]], @"%@: not a UILayer!", ←
NSStringFromSelector(_cmd));
return (UserInterfaceLayer*)layer;
}
This makes it easy to access the various layers from any node of the MultiLayerS-
cene .
▪ You can access the “scene” layer of MultiLayerScene :
MultiLayerScene* sceneLayer = [MultiLayerScene
sharedLayer];
▪ You can access the other layers through the scene layer:
GameLayer* gameLayer = [sceneLayer gameLayer];
UserInterfaceLayer* uiLayer = [sceneLayer uiLay-
er];
▪ As an alternative, because of the @property definition, you can also use
the dot accessor. Whichever you prefer is up to you, as long as you stick
to it consistently. Technically and performance-wise, there's absolutely no
difference.
GameLayer* gameLayer = sceneLayer.gameLayer;
UserInterfaceLayer* uiLayer = sceneLayer.uiLayer;
Search Nedrilad ::




Custom Search