1. Message notification hubs (CCNOTIFICATIONCENTER) (Observer mode)
Role: communication between each layer class 2 post message: Ccnotificationcenter::sharednotificationcenter ()->postnotification (char * message ID, ccobject* delivery parameters); 3 Receive Message: Ccnotificationcenter::sharednotificationcenter ()->addobserver (ccobject* target class (this), Callfunco_ Selector (callback function),char * message ID, NULL); 4 callback function:void function name (ccobject *obj); 5 Remove message: Ccnotificationcenter::sharednotificationcenter ()->removeobserver (ccobject* target class (char* message ID);
2. Custom Picture text:
1 Cclabelatlas
3. Add resource File Search path:
1 std::vector<std::string> vecrespath; 2 vecrespath.push_back (" path "); 3 vecrespath.push_back (" path "); 4 ccfileutils::sharedfileutils ()->setsearchpaths (Vecrespath);
4. User Data Center, will write the data into XML, the next time you start to continue to read
1 ccuserdefault::shareduserdefault ()->setboolforkey ("isgamestart" True); 2 After the setup is complete, be sure to call flush () to write to the file
5. Get the original size of the note:
1 ccnote ()->getcontentsize ()
6. Delay Action:
1 ccactioninterval
7. Spline Action:
1 cccardinalsplineby::create (floatfloat tension);2float Duration // time interval 3 ccpointarray points // control point list 4 float tension // elastic degree. When Tension==1, the spline is a segmented line. Tension < 1 outward slack bent, tension > 1 inward shrink bent.
8. Change the Movement speed
1 Cceasein- from slow to fast (linear change in speed), at the beginning of 2 cceaseout slow- from fast to slow, then slower 3 cceaseinout- From slow to fast again from fast to slow, start and later slow 4 Cceasesinein- from slow to fast (speed sine change)5 cceasesineout- from fast to slow 6 Cceasesineinout- from slow to fast again from fast to slow 7 Cceaseexponentialin- from very slow to very fast (speed-to-scale change)8 Cceaseexponentialout- from extremely fast to slow 9 Cceaseexponentialinout-from extremely fast to slow
9. Point 9 figure
1 ccscale9sprite
10. Determine if a point is in a rectangle
1 ccrect.containspoint (ccpoint)
11. Play Sound
1 cocosdenshion::simpleaudioengine::sharedengine ()->playeffect (" file path ");
12. Touch Events
1 Cctouchbegan 2 cctouchmoved 3 cctouchended
13. Do not call the Addchlid () method in OnEnter ().
the difference between init () and OnEnter ():
The order in which it is called is First init (), followed by OnEnter ().
Init () is called only once during initialization of the class.
OnEnter () is called when the class is loaded into the scene and may occur more than once.
For example: cclayer* cclayer = new Mylayer (); In this case, only the onenter will be triggered.
cclayer* Cclayer = Mylayer::create (), in which case both the init () method is triggered and the OnEnter () method is triggered.
cocos2d-Essay Records