- Cocos2d-x Cookbook
- Akihiro Matsuura
- 303字
- 2021-07-09 20:58:47
Preparing your original game
In the next chapter, we will start the original game. You know there are a lot of comments and codes in HelloWorldScene.cpp
and the HelloWorldScene.h
file. That's why we will remove unnecessary codes in the template project and get started with the original game right away.
How to do it…
- Open
HelloWorldScene.h
and remove themenuCloseCallback
method and unnecessary comments. NowHelloWorldScene.h
should look like the following code:#ifndef __HELLOWORLD_SCENE_H__ #define __HELLOWORLD_SCENE_H__ #include "cocos2d.h" class HelloWorld : public cocos2d::Layer { public: static cocos2d::Scene* createScene(); virtual bool init(); CREATE_FUNC(HelloWorld); }; #endif // __HELLOWORLD_SCENE_H__
- The next step is to open
HelloWorldScene.cpp
and remove unnecessary comments, codes, and methods. NowHelloWorldScene.cpp
should look like the following code:#include "HelloWorldScene.h" USING_NS_CC; Scene* HelloWorld::createScene() { auto scene = Scene::create(); auto layer = HelloWorld::create(); scene->addChild(layer); return scene; } bool HelloWorld::init() { if ( !Layer::init() ) { return false; } return true; }
- The next step is to remove unnecessary images in
resources
. RemoveCloseNormal.png
,CloseSelected.png
andHelloWorld.png
from theResources
folder in Xcode: - Finally, if you are developing only iOS and Android applications, you don't need files for other platforms such as Linux, Windows, and Windows Phone. You should remove these files.
Before removing platform files, it should look like the following screenshot:
After removing platform files, it should look like the following screenshot:
How it works…
With this recipe, you can get the simplest project ready before removing unnecessary comments, codes, and methods. Removing unnecessary platform codes and resources is important for reducing the size of your application. If you start building your original game from scratch, you will need to follow this recipe or chances are, you may get a black screen if you build and run this project. In the next chapter, you can start coding within this simple project.
- Vue.js 3.x快速入門
- 零基礎PHP學習筆記
- 深入理解Django:框架內幕與實現原理
- HDInsight Essentials(Second Edition)
- R用戶Python學習指南:數據科學方法
- 打開Go語言之門:入門、實戰與進階
- 21天學通C++(第5版)
- 零基礎輕松學C++:青少年趣味編程(全彩版)
- Practical GIS
- Python Projects for Kids
- Application Development with Swift
- MATLAB 2020 GUI程序設計從入門到精通
- ArcPy and ArcGIS(Second Edition)
- 讓Python遇上Office:從編程入門到自動化辦公實踐
- Scratch超人漫游記:創意程序設計:STEAM創新教育指南