![]() |
Cornell Cocos
Cornell Extensions to Cocos2d
|
#include <CULoader.h>
Public Member Functions | |
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 | loadCount () const |
virtual size_t | waitCount () const |
bool | isComplete () const |
float | progress () const |
CC_CONSTRUCTOR_ACCESS | _active (false) |
virtual | ~BaseLoader () |
Public Attributes | |
CC_CONSTRUCTOR_ACCESS | __pad0__: BaseLoader() : Ref() |
Protected Attributes | |
bool | _active |
Class provides a polymorphic base to the loader system.
This is effectively a Java-style interface. It identifies the methods that all loaders must have, and provides a type for the AssetManager to use in its underlying storage container.
|
inlinevirtual |
Diposes the base loader, releasing all resources
This destructor is protected, as loaders will use Cocos2d's reference counting system for garbage collection.
|
inline |
Returns true if this resource loader is active.
An active resource loader is one that can load assets (e.g. method start() has been called).
|
inline |
Returns true if the loader has finished loading all assets.
It is not safe to use asynchronously loaded assets until all loading is complete. This method allows us to determine when asset loading is complete.
|
inlinevirtual |
Adds a new asset to the loading queue.
The asset will be loaded asynchronously. When it is finished loading, it will be added to this loader, and accessible under the given key. This method will mark the loading process as not complete, even if it was completed previously. It is not safe to access the loaded asset until it is complete again.
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, GenericBaseLoader, and SoundLoader.
|
inlinevirtual |
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.
This method is abstract and should be overridden in the specific implementation for each asset.
Reimplemented in GenericLoader< T >, Loader< T >, Loader< Asset >, Loader< Sound >, Loader< Texture2D >, and Loader< TTFont >.
|
inline |
Returns the loader progress as a percentage.
This method returns a value between 0 and 1. A value of 0 means no assets have been loaded. A value of 1 means that all assets have been loaded.
Anything in-between indicates that there are assets which have been loaded asynchronously and have not completed loading. It is not safe to use asynchronously loaded assets until all loading is complete.
|
inlinevirtual |
Starts this resource loader.
This method bootstraps the loader with any initial resources that it needs to load assets. Attempts to load an asset before this method is called will fail.
By separating this call from the constructor, this allows us to construct loaders and attach them to the AssetManager before we are ready to load assets.
This method is abstract and should be overridden in the specific implementation for each asset.
Reimplemented in GenericLoader< T >, FontLoader, TextureLoader, GenericBaseLoader, and SoundLoader.
|
inlinevirtual |
Stops this resource loader removing all assets.
Any assets loaded by this loader will be immediately released by the loader. However, an asset may still be available if it is attached to another loader. See the description of the specific implementation for how assets are released.
Once the loader is stopped, any attempts to load a new asset will fail. You must call start() to begin loading assets again.
This method is abstract and should be overridden in the specific implementation for each asset.
Reimplemented in GenericLoader< T >, FontLoader, TextureLoader, GenericBaseLoader, and SoundLoader.
|
inlinevirtual |
Unloads the asset for the given key.
An asset may still be available if it is attached to another loader. See the description of the specific implementation for how assets are released.
This method is abstract and should be overridden in the specific implementation for each asset.
key | the key referencing the asset |
Reimplemented in GenericLoader< T >, FontLoader, TextureLoader, GenericBaseLoader, and SoundLoader.
|
inlinevirtual |
Unloads all assets present in this loader.
An asset may still be available if it is attached to another loader. See the description of the specific implementation for how assets are released. This method is similar to stop(), except that new assets can be loaded.
This method is abstract and should be overridden in the specific implementation for each asset.
Reimplemented in GenericLoader< T >, FontLoader, TextureLoader, GenericBaseLoader, and SoundLoader.
|
inlinevirtual |
Returns the number of assets waiting to load.
This is a rough way to determine how many assets are still pending. An asset is pending if it has been loaded asychronously, and the loading process has not yet finished. This method counts each asset equally regardless of the memory requirements of each asset.
This method is abstract and should be overridden in the specific implementation for each asset.
Reimplemented in GenericLoader< T >, FontLoader, TextureLoader, GenericBaseLoader, and SoundLoader.
|
protected |
Whether or not this resource loader is active