

Layers may contain any CCNode as a child, including CCSprites, CCLabels, and even other CCLayer objects. Examples are:- CCMenu is a menu layer which is used to add menus, CCColorLayer is a layer that draws a solid color. When we desing complex applications that may require us to define custom CCLayer subclasses, cocos2d provides several predefined layers. These touch events are propagated to all the layers within a scene, from front to back, until some layer catches the event and accepts it. we can implement methods to handle one of the touch events (ccTouchBegan, ccTouchMoved, ccTouchEnded, or ccTouchCancelled) a CCLayer can react to the player’s interaction. CCLayers are very useful in defining our game’s appearance and behavior, so we should expect to spend a lot of our programming time coding CCLayer subclasses that do what you need. Layers allow us to add child to it eg: we can add our ccsprites and menuImages.
#Ccmenu add child cocos2dx how to#
Again, when you pop the top scene from the stack, the paused scene resumes from its last state.When you use replace scene the scene is replaced by the new scene and the previous scene will be deleted from the memory.Ī CCLayer is treated as CCNode that knows how to handle touch events. When you push a new scene onto the stack, the Director pauses the previous scene but keeps it in memory. Director knows which scene is currently active and allows you to change scenes by replacing the current scene or pushing a new one onto the scene stack by using the two methods pushScene and replaceScene. CCDirector is a shared ( which is known as singleton) object that takes care of navigating between scenes eg: homeScene and gameScene and helpScene.
