Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Cocos2d-X Game Development Blueprints

You're reading from   Cocos2d-X Game Development Blueprints Build a plethora of games for various genres using one of the most powerful game engines, Cocos2d-x

Arrow left icon
Product type Paperback
Published in Jul 2015
Publisher Packt
ISBN-13 9781783985265
Length 392 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Karan Sequeira Karan Sequeira
Author Profile Icon Karan Sequeira
Karan Sequeira
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. A Colorful Start FREE CHAPTER 2. How to Fly a Dragon! 3. Not Just a Space Game 4. Back to the Drawing Board 5. Let's Get Physical! 6. Creativity with Textures 7. Old is Gold! 8. Box2D Meets RUBE 9. The Two Towers 10. Cross-platform Building Index

Getting acquainted with the project structure

The main backbone files required for any Cocos2d-html5 game are the index.html, main.js, and cocos2d.js files. These are exactly the files you will see in your project's root directory. In addition to these three files, you can also see a file called build.xml and another file called cocos2d-jsb.js. Take a look at the following table for a brief description of what these files are responsible for:

File

Description

index.html

This is the main HTML page that will be displayed on any device's browser. This is where your game will run. This is also the file you must double-click on in order to launch the game in a browser.

main.js

This file could be compared to the AppDelegate class from Cocos2d-x. It is the starting point of our game and is where the director is informed of which the game's first scene should be.

cocos2d.js

This file is the main configuration file and is the only source file that gets linked to your HTML page. This file is responsible for invoking the engine's main loader. Any sources that go into your game need to be listed in this file.

cocos2d-jsb.js

This JavaScript source file is required to boot JavaScript bindings and is not required for Cocos2d-html5. You could delete this file if you don't intend on using JavaScript bindings.

build.xml

You can compress your entire game's source code into a single file using the Google Closure Compiler that is provided under the tools directory of the Cocos2d-html5 source. This file is the input to the Ant build command that invokes the compiler. To run this, you will need Ant and JRE installed on your machine.

resources.js

This file contains a JSON object that lists all the resources that you will need to run the game. You must ensure that each and every resource (image, plist, font, audio, and so on) is included in this file. Not doing so will most certainly crash your application.

The engine will then load all the files listed in this file into the browser's memory. Therefore, you will still need to load the textures, sprite frames and animations into their respective caches.

Now that we have a basic understanding of the structure of a typical Cocos2d-html5 project, it is time to create our very first scene in ColourSmash.

You have been reading a chapter from
Cocos2d-X Game Development Blueprints
Published in: Jul 2015
Publisher: Packt
ISBN-13: 9781783985265
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image