Cocos2dx:CCLayer
lastmod 2018-08-17created 2017-11-101 edits
Features
- Has the size of a drawable area and defines how drawing is implemented.
- Can be rendered overlapping other Layers semi-transparently
- A class that implements an Event Handler (an Event propagates until a specific Layer receives and handles it)
- cocos2D predefines useful CCLayers (menu: CCMenu, color: CCColorLayer, multiplexer: CCMultiplexLayer, ... and of course you can implement a user-defined CCLayer)
- Since it is a SubClass of CCNode, it can be transformed by Actions.
Scene creation and destruction order
The method call order of CCLayer is as follows.
- Constructor.
- virtual bool init();
- virtual void onEnter();
- virtual void onEnterTransitionDidFinish();
- virtual void onExit();
- Destructor.
Mouse click events
default implements are used to call script callback if exist
virtual bool ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent);
virtual void ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent);
virtual void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent);
virtual void ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent);
virtual void ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent);
virtual void ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent);
virtual void ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent);
virtual void ccTouchesCancelled(CCSet *pTouches, CCEvent *pEvent);