The avi version can be conveniently viewed on mobile phones and PCs.
1. Play background music and real-time music
# Include SimpleAudioEngine. hCocosDenshion: SimpleAudioEngine: sharedEngine ()-> audio); // real-time music cococosdenshion: SimpleAudioEngine: sharedEngine ()-> audio, true); // Loop Playing background audio
2. Create a scenario
You can switch between scenarios and implement delayed actions.
// GameOverLayer. h # include cocos2d. hclass GameOverLayer: public cocos2d: CCLayerColor {public: cocos2d: CCLabelTTF * _ label; bool init ();~ GameOverLayer (); static cocos2d: CCScene * scene (); CREATE_FUNC (GameOverLayer); void returnToGame (cocos2d: CCNode *); // CCLabelTTF: create () HelloWorld :: create ()}; // GameOverLayer. cpp # include GameOverLayer. h # include HelloWorldScene. hUSING_NS_CC; bool GameOverLayer: init () {if (CCLayerColor: initWithColor (ccc4 (0,255, 0,255) {_ label = CCLabelTTF: create (word, Artial, 40); CCSize size = CCDirector: shared Director ()-> getVisibleSize (); _ label-> setPosition (ccp (size. width/2, size. height/2); this-> addChild (_ label); _ label-> retain (); // ensure that the _ label and the class object have the same lifecycle CCDelayTime * delay = CCDelayTime: create (5); // execute a delayed action CCCallFuncN * returnToGame = CCCallFuncN :: create (this, callfuncN_selector (GameOverLayer: returnToGame); this-> runAction (CCSequence: create (delay, returnToGame, NULL); return true;} return false ;} Void GameOverLayer: returnToGame (CCNode *) {CCDirector: sharedDirector ()-> replaceScene (HelloWorld: scene (); // switch between scenarios} GameOverLayer ::~ GameOverLayer () {if (_ label) {_ label-> release () ;}} cocos2d: CCScene * GameOverLayer: scene () {CCScene * scene = CCScene :: create (); GameOverLayer * layer = GameOverLayer: create (); layer-> setTag (100); scene-> addChild (layer); return scene ;}
Uploaded to Youku
Http://v.youku.com/v_show/id_XNjY0MjEzNzI0.htmlLesson 1
Http://v.youku.com/v_show/id_XNjY0MjMzMzYw.html 2nd
Http://v.youku.com/v_show/id_XNjY0MjU1OTcy.html 3rd
Http://v.youku.com/v_show/id_XNjY0MzQxMDE2.html 4th
Http://v.youku.com/v_show/id_XNjY1MTI3NjYw.html 5th
Http://v.youku.com/v_show/id_XNjY1MTI5ODQw.html 6th
Please download HD from Baidu online storage.
Reprinted please indicate the source: http://blog.csdn.net/xingxiliang/article/details/18681575