Cornell Cocos
Cornell Extensions to Cocos2d
|
#include <CUSound.h>
Public Member Functions | |
const std::string & | getSource () const |
std::string | getSuffix () const |
float | getDuration () const |
bool | isPreloaded () const |
CC_CONSTRUCTOR_ACCESS | _source ("") |
CC_CONSTRUCTOR_ACCESS | _duration (0.0f) |
~Sound () | |
bool | init (std::string source) |
bool | init (std::string source, float duration) |
Static Public Member Functions | |
static Sound * | create (std::string source) |
static Sound * | create (std::string source, float duration) |
Public Attributes | |
CC_CONSTRUCTOR_ACCESS | __pad0__: Sound() : Ref() |
Protected Attributes | |
std::string | _source |
float | _duration |
Friends | |
class | SoundLoader |
Class provides a reference to a (potentially) loaded asset.
We say potentially because Android has substantially inferior sound capabilities and cannot preload sounds. This means that the asset handling for Android is very different from other platforms. To avoid this, we introduce this class as a way of handling the sound across all platforms. It can refer to a sound that is preloaded, or one that should be loaded when used.
This class uses Cocos2d reference counting for memory management. The constructors are protected because only the SoundLoader should construct sounds.
|
inline |
Deletes this sound object
The sound should be unloaded before deletion.
|
static |
Creates a new sound object for the given source file.
The sound file has no duration, indicating that it was not preloaded.
source | the source file for the sound |
|
static |
Creates a new sound object for the given source file.
The sound file has a duration, indicating that it was preloaded.
source | the source file for the sound |
duration | the duration of the sound file |
|
inline |
Returns the duration of this sound file.
If the file has not been preloaded, we cannot determine the duration. In that case, the duration is experimental::AudioEngine::TIME_UNKNOWN.
|
inline |
Returns the source file for this sound.
|
inline |
Returns the file suffix for this sound.
Until we expose more functionality about the encoding, this is a poor man's way of determining the file format.
|
inline |
Initializes a new sound object for the given source file.
The sound file has no duration, indicating that it was not preloaded.
source | the source file for the sound |
|
inline |
Initializes a new sound object for the given source file.
The sound file has a duration, indicating that it was preloaded.
source | the source file for the sound |
duration | the duration of the sound file |
|
inline |
Returns true if the sound file was preloaded.
This should return true on any platform that is not Android or Linux.
|
friend |
Allow the sound loader access to the constructors
|
protected |
The duration of the sound asset
|
protected |
The source file for the sound