![]() |
Cornell Cocos
Cornell Extensions to Cocos2d
|
#include <CULoader.h>
Public Member Functions | |
virtual bool | contains (std::string key) const |
virtual T * | get (std::string key) const |
T * | operator[] (std::string key) const |
virtual size_t | loadCount () const override |
virtual T * | load (std::string key, std::string source) |
![]() | |
virtual void | start () |
virtual void | stop () |
bool | isActive () const |
virtual void | loadAsync (std::string key, std::string source) |
virtual void | unload (std::string key) |
virtual void | unloadAll () |
virtual size_t | waitCount () const |
bool | isComplete () const |
float | progress () const |
CC_CONSTRUCTOR_ACCESS | _active (false) |
virtual | ~BaseLoader () |
Protected Attributes | |
std::unordered_map< std::string, T * > | _assets |
![]() | |
bool | _active |
Additional Inherited Members | |
![]() | |
CC_CONSTRUCTOR_ACCESS | __pad0__: BaseLoader() : Ref() |
Type specific template for each loader.
This template works like a generic abstract class in Java. I provides some type correctness. It also provides some base functionality that is common for all loaders. Methods marked as abstract must be overriden in specific loader implementations.
All assets are assigned a key and retrieved via that key. This for a quick way to reference assets.
|
inlinevirtual |
Returns true if the key maps to a loaded asset.
This method is useful in case the asset fails to load.
key | the key associated with the asset |
Reimplemented in GenericLoader< T >.
|
inlinevirtual |
Returns the asset for the given key.
If the key is valid, the asset is guaranteed not to be null. Otherwise, this method returns nullptr
key | the key associated with the asset |
Reimplemented in GenericLoader< T >.
|
inlinevirtual |
Loads an asset and assigns it to the given key.
The asset will be loaded synchronously. It will be available immediately. This method should be limited to those times in which an asset is really necessary immediately, such as for a loading screen.
This method is abstract and should be overridden in the specific implementation for each asset.
key | The key to access the asset after loading |
source | The pathname to the asset |
Reimplemented in GenericLoader< T >, FontLoader, TextureLoader, SoundLoader, and GenericBaseLoader.
|
inlineoverridevirtual |
Returns the number of assets currently loaded.
This is a rough way to determine how many assets have been loaded so far. This method counts each asset equally regardless of the memory requirements of each asset.
Reimplemented from BaseLoader.
Reimplemented in GenericLoader< T >.
|
inline |
Returns the asset for the given key.
If the key is valid, the asset is guaranteed not to be null. Otherwise, this method returns nullptr
key | the key associated with the asset |
|
protected |
Hash map storing the loaded assets