Skip to content

Instantly share code, notes, and snippets.

@solkar
Created January 27, 2014 16:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save solkar/8651478 to your computer and use it in GitHub Desktop.
Save solkar/8651478 to your computer and use it in GitHub Desktop.
cocos2d-x C++ singleton
#include "GameManager.h"
using namespace cocos2d;
static GameManager *_sharedGameManager = NULL;
GameManager* GameManager::getInstance()
{
if (! _sharedGameManager)
{
_sharedGameManager = new GameManager();
_sharedGameManager->init();
}
return _sharedGameManager;
}
GameManager::~GameManager(void)
{
}
bool GameManager::init(void)
{
return true;
}
#include "cocos2d.h"
class GameManager : public cocos2d::Object
{
public:
/** Returns the shared instance of the Game Manager */
static GameManager* getInstance(void);
public:
virtual ~GameManager();
bool init(void);
};
@Dominicanos
Copy link

how can implement destroy _sharedGameManager for clear the vector and take other sprite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment