Get the App
SLTechnology News&Howtos  ›  Development  › 

What does the Scene in Cocos2dx mean?

Shulou Source: shulou.com Published: 2022-06-02 03:32:18 10月02日 Update

In this issue, the editor will bring you about what Scene in Cocos2dx refers to. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

Scene is the direct representation element of the game, and the game is constructed from several different scenarios. The level switch in the game, the map switch is actually the switch of the game scene. And all these processes are controlled by Director.

Open the AppDelegate.cpp file in the project.

Reference header file # include "HelloWorldScene.h"

Auto scene = HelloWorld::createScene (); / / call HelloWorld::createScene () to create the scene

Director- > runWithScene (scene); / / initialize the game to enter the first scene and call it

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

The first step 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, only as an abstract concept.

The function to create a scene: static Scene * create () / / create a new scene object.

In addition, for the common methods of controlling scenes with Director, please refer to:

Cocos2dx Learning Notes 4: director (Director) http://www.byjth.com/biji/23.html

Usually we create a subclass of Scene, initialize the game resources in the subclass, add layers to the scene (Layer), start music playback, and so on.

This is what the Scene in the Cocos2dx shared by the editor refers to. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Tags: Scene subclass file switch content that is game scene analysis control different professional small and medium code creative element entry level rich content function map Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Xiaomi Docker OPPO Reno Huawei