![]() |
Cornell Cocos
Cornell Extensions to Cocos2d
|
#include <CUAssetManager.h>
Public Member Functions | |
int | createScene () |
void | startScene (int scene) |
void | startAll () |
void | stopScene (int scene) |
void | stopAll () |
void | deleteScene (int scene) |
void | deleteAll () |
bool | hasScene (int scene) const |
int | getCurrentIndex () const |
void | setCurrentIndex (int scene) |
SceneManager * | getCurrent () const |
SceneManager * | at (int scene) const |
SceneManager * | operator[] (int scene) const |
Static Public Member Functions | |
static void | init () |
static void | shutdown () |
static AssetManager * | getInstance () |
Protected Attributes | |
std::vector< SceneManager * > | _managers |
int | _scene |
Static Protected Attributes | |
static AssetManager * | _gManager = nullptr |
Singleton class to support asset management.
Assets should always be managed by a central loader. Cocos2D appears to have these things all over the place. This helps centralize them. This is particularly useful when implementing scene management.
In scene management, each asset is attached to a scene. This allows you to unload all of the assets for a scene without unloading all assets. It is possible for an asset to be attached to multiple scenes. In that case, the scenes will attach a reference count, and the asset will only be unloaded when all associated scenes are unloaded.
This class is a singleton, in the same way that director is. That mean you should not create new instances of this object (and the constructor is protected for that very reason). Instead, you should use the static method getInstance().
|
inline |
Returns the scene manager for the given index.
If the scene is invalid, this method will raise an exception.
scene | The index for the scene manager |
int AssetManager::createScene | ( | ) |
Creates a new scene for managing assets.
The new scene will be set as the current scene.
void AssetManager::deleteAll | ( | ) |
Deletes all of the allocated scene managers.
This method will stop the scene managers if they are still active. It will clear the asset manager and future attempts to access the previously allocated scene managers will raise an exception.
void AssetManager::deleteScene | ( | int | scene | ) |
Deletes the scene manager for the given index
This method will stop the scene manager if it is still active. Future attempts to access a scene manager for this index will raise an exception.
scene | The index for the scene manager |
|
inline |
Returns the scene manager for the current scene.
If there is no active scene, this method will return nullptr.
|
inline |
Returns the index for the current scene.
If there is no current scene, this method will return -1.
|
inlinestatic |
Returns a reference tot he global asset manager.
|
inline |
Returns True if scene corresponds to an allocated scene.
In general, this method will return false if scene was deleted. However, the scene identifier may be reused by later allocations.
|
static |
Initializes the global asset manager.
This should be called when the application starts
|
inline |
Returns the scene manager for the given index.
If the scene is invalid, this method will raise an exception.
scene | The index for the scene manager |
|
inline |
Sets the index for the current scene.
If there is no current scene, this method will return -1.
scene | The index for the current scene. |
|
static |
Stops the global asset manager.
This releases all of the allocated scene managers. It should be called when the application quits.
void AssetManager::startAll | ( | ) |
Starts all of the allocated scene managers.
void AssetManager::startScene | ( | int | scene | ) |
Starts the scene manager for the given index
scene | The index for the scene manager |
void AssetManager::stopAll | ( | ) |
Stops all of the allocated scene managers.
void AssetManager::stopScene | ( | int | scene | ) |
Stops the scene manager for the given index
scene | The index for the scene manager |
|
staticprotected |
The singleton asset manager
Initialization of static reference
|
protected |
The managers for each individual scene
|
protected |
The current active scene