COCOS2DX Study Note 5: Scenes (Scene)

Source: Internet
Author: User

Scene (Scene) is the direct expression of the game elements, the game is built from a number of different scenes. The game inside the level switch, the map switch is actually the game scene switch. And all of these processes are controlled by the Director .

Open in Project AppDelegate.cpp file.   

650) this.width=650; "style=" Border-bottom:medium none;border-left:medium none;border-top:medium none;border-right: Medium none; "Title=" Click to view the original "border=" 0 "alt=" study Note 5: Figure 1.png "src=" http://www.byjth.com/content/uploadfile/201508/ 8e451440646226.png "width=" 507 "height=" 369 "/>

#include  

auto  scene  =  helloworld

director->runwithscene (scene); //Initialize the game into the first scene call it

The entrance to the game scene is realized through 2 lines of code.

The first is to call Helloworld::createscene () to create the scene, and then run the created scene.


Opening the CCScene.h file in the D:\cocos2d-x-3.4\cocos\2d directory, we can see that the scene is a subclass of Node, just as an abstract concept.

functions for creating scenes: Static Scene * Create () //Creates a new scene object.

650) this.width=650; "style=" Border-bottom:medium none;border-left:medium none;border-top:medium none;border-right: Medium none; "Title=" Click to view the original "border=" 0 "alt=" study Note 5: Figure 2.png "src=" http://www.byjth.com/content/uploadfile/201508/ 69d51440646365.png "width=" 567 "height=" 327 "/>

In addition to the common methods of Director control scenarios, please refer to:

COCOS2DX Study Note 4: Directors (director) http://www.byjth.com/biji/23.html

usually we create a subclass of a scene and load the game resources into the subclasses, adding layers to the scene (Layer) , start music playback, and so on.

This article by closed eyes on the dark finishing editing, reprint please specify: http://www.byjth.com/biji/24.html | Close your eyes on the Dark column _ Original blog

This article from "Close your eyes on the Dark" blog, reprint please contact the author!

COCOS2DX Study Note 5: Scenes (Scene)

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.