Cocos2dx game development simple getting started video tutorial (cocos2d-x)-4th days

Source: Internet
Author: User

 

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.