Defining the global variables of the game
Every game we make henceforth will have a common header file included and global data defined in a separate class. This class has been made for convenience only and—technically—you can choose not to have it at all. However, all the enums, constants, and macros used in the game will be stored here, so be sure to include it in the sources where needed.
Let's take a look at the GameGlobals.h
file:
#ifndef GAME_GLOBALS_H_ #define GAME_GLOBALS_H_ #include "cocos2d.h" #include "SimpleAudioEngine.h" USING_NS_CC; using namespace std; #define SCREEN_SIZE GameGlobals::screen_size_ #define SOUND_ENGINE CocosDenshion::SimpleAudioEngine::sharedEngine() #define MAX_STARS 15 #define BULLET_MOVE_DURATION 1.5f #define MAX_BULLETS 25 #define MAX_LEVELS 5 // enum used for proper z-ordering enum E_ZORDER { E_LAYER_BACKGROUND = 0, E_LAYER_FOREGROUND = 2, E_LAYER_ENEMIES_BRICKS = 4, E_LAYER_BULLETS = 6, E_LAYER_PLAYER...