Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What does the Scene in Cocos2dx mean?

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report