Cornell Cocos
Cornell Extensions to Cocos2d
Public Member Functions | Public Attributes | Protected Attributes | List of all members
Asset Class Referenceabstract

#include <CUAsset.h>

Inheritance diagram for Asset:

Public Member Functions

std::string getFile () const
 
void setFile (std::string file)
 
virtual bool load ()=0
 
virtual void unload ()
 
virtual ~Asset ()
 
bool init ()
 
bool init (std::string file)
 

Public Attributes

CC_CONSTRUCTOR_ACCESS __pad0__: Asset() : Ref() { _file = ""
 

Protected Attributes

std::string _file
 

Detailed Description

An abstract class for a generic asset

This class is the base class for any generic asset (such as a model file or level layout) not explicitly included in the existing asset classes. It has abstract methods for loading and unloading from a file, which any subclass should implement.

This class SHOULD NOT make any references to AssetManager in the load/unload methods. Assets should be treated as if they load in parallel, not in sequence. Therefore, it is unsafe to assume that one asset loads before another. If this asset needs to connect to other assets (sound, images, etc.) this should take place after asset loading, such as during scene graph initialization or the like.

Constructor & Destructor Documentation

virtual Asset::~Asset ( )
inlinevirtual

Deletes this asset, disposing all resources.

Member Function Documentation

std::string Asset::getFile ( ) const
inline

Returns the source file associate with this asset.

Returns
the source file associate with this asset.
bool Asset::init ( )
inline

Initializes a new asset with no source file.

The source file can be set at any time via the setFile() method. This method does NOT load the asset. You must call the load() method to do that.

Returns
true if the asset is initialized properly, false otherwise.
bool Asset::init ( std::string  file)
inline

Initializes a new asset with the given source file.

This method does NOT load the asset. You must call the load() method to do that. This method returns false if file does not exist.

Returns
true if the asset is initialized properly, false otherwise.
virtual bool Asset::load ( )
pure virtual

Returns true after successfully loading from a file.

This method is abstract. All subclasses should provide an implementation of this method. This method is necessary for an Asset to be used with an instance of GenericLoader.

This load method should NEVER access the AssetManager. Assets are loaded in parallel, not in sequence. If an asset (like a game level) has references to other assets, then these should be connected later, such as during scene graph initialization.

Returns
true if successfully loaded the asset from a file
void Asset::setFile ( std::string  file)
inline

Sets the source file associate with this asset.

This method does not reload the asset, but later calls to load will use this file in place of any previous one.

Parameters
filethe source file associate with this asset.
virtual void Asset::unload ( )
inlinevirtual

Unloads all resources attached to this file.

This method is abstract. All subclasses should provide an implementation of this method. This method is necessary for an Asset to be used with an instance of GenericLoader.

This load method should NEVER access the AssetManager. Assets are loaded and unloaded in parallel, not in sequence. If an asset (like a game level) has references to other assets, then these should be disconnected earlier.

Member Data Documentation

std::string Asset::_file
protected

The source file associated with this asset


The documentation for this class was generated from the following file: