cocos2d-x  2.2.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SimpleAudioEngine Class Reference

offer a VERY simple interface to play background music & sound effect More...

#include <SimpleAudioEngine.h>

Inheritance diagram for SimpleAudioEngine:
TypeInfo

Public Member Functions

 SimpleAudioEngine ()
 ~SimpleAudioEngine ()
virtual long getClassTypeInfo ()
void preloadBackgroundMusic (const char *pszFilePath)
 Preload background music. More...
 
void playBackgroundMusic (const char *pszFilePath, bool bLoop)
 Play background music. More...
 
void playBackgroundMusic (const char *pszFilePath)
void stopBackgroundMusic (bool bReleaseData)
 Stop playing background music. More...
 
void stopBackgroundMusic ()
void pauseBackgroundMusic ()
 Pause playing background music. More...
 
void resumeBackgroundMusic ()
 Resume playing background music. More...
 
void rewindBackgroundMusic ()
 Rewind playing background music. More...
 
bool willPlayBackgroundMusic ()
bool isBackgroundMusicPlaying ()
 Whether the background music is playing. More...
 
float getBackgroundMusicVolume ()
 The volume of the background music max value is 1.0,the min value is 0.0. More...
 
void setBackgroundMusicVolume (float volume)
 set the volume of background music More...
 
var setMusicVolume ( var volume)
 set the volume of background music More...
 
local setBackgroundMusicVolume ( local volume)
 set the volume of background music More...
 
float getEffectsVolume ()
 The volume of the effects max value is 1.0,the min value is 0.0. More...
 
void setEffectsVolume (float volume)
 set the volume of sound effecs More...
 
unsigned int playEffect (const char *pszFilePath, bool bLoop)
 Play sound effect. More...
 
local playEffect ( local pszFilePath, local bLoop)
 Play sound effect. More...
 
unsigned int playEffect (const char *pszFilePath)
void pauseEffect (unsigned int nSoundId)
 Pause playing sound effect. More...
 
void pauseAllEffects ()
 Pause all playing sound effect. More...
 
var pauseAllEffects ()
 Pause all playing sound effect. More...
 
local pauseAllEffects ()
 Pause all playing sound effect. More...
 
void resumeEffect (unsigned int nSoundId)
 Resume playing sound effect. More...
 
void resumeAllEffects ()
 Resume all playing sound effect. More...
 
void stopEffect (unsigned int nSoundId)
 Stop playing sound effect. More...
 
void stopAllEffects ()
 Stop all playing sound effects. More...
 
void preloadEffect (const char *pszFilePath)
 preload a compressed audio file More...
 
var preloadEffect ( var pszFilePath)
 preload a compressed audio file More...
 
local preloadEffect ( local pszFilePath)
 preload a compressed audio file More...
 
void unloadEffect (const char *pszFilePath)
 unload the preloaded effect from internal buffer More...
 

Static Public Member Functions

static SimpleAudioEnginesharedEngine ()
 Get the shared Engine object,it will new one when first time be called. More...
 
local sharedEngine ()
 Get the shared Engine object,it will new one when first time be called. More...
 
static void end ()
 Release the shared Engine object. More...
 

Detailed Description

offer a VERY simple interface to play background music & sound effect

Constructor & Destructor Documentation

local SimpleAudioEngine ( )

Member Function Documentation

static void end ( )
static

Release the shared Engine object.

Warning
It must be called before the application exit, or a memroy leak will be casued.
var end ( )
static

Release the shared Engine object.

Warning
It must be called before the application exit, or a memroy leak will be casued.
float getBackgroundMusicVolume ( )

The volume of the background music max value is 1.0,the min value is 0.0.

var getMusicVolume ( )

The volume of the background music max value is 1.0,the min value is 0.0.

local getBackgroundMusicVolume ( )

The volume of the background music max value is 1.0,the min value is 0.0.

virtual long getClassTypeInfo ( )
inlinevirtual

Implements TypeInfo.

float getEffectsVolume ( )

The volume of the effects max value is 1.0,the min value is 0.0.

var getEffectsVolume ( )

The volume of the effects max value is 1.0,the min value is 0.0.

local getEffectsVolume ( )

The volume of the effects max value is 1.0,the min value is 0.0.

bool isBackgroundMusicPlaying ( )

Whether the background music is playing.

Returns
If is playing return true,or return false
var isMusicPlaying ( )

Whether the background music is playing.

Returns
If is playing return true,or return false
local isBackgroundMusicPlaying ( )

Whether the background music is playing.

Returns
If is playing return true,or return false
void pauseAllEffects ( )

Pause all playing sound effect.

Parameters
nSoundIdThe return value of function playEffect
var pauseAllEffects ( )

Pause all playing sound effect.

Parameters
nSoundIdThe return value of function playEffect
local pauseAllEffects ( )

Pause all playing sound effect.

Parameters
nSoundIdThe return value of function playEffect
void pauseBackgroundMusic ( )

Pause playing background music.

var pauseMusic ( )

Pause playing background music.

local pauseBackgroundMusic ( )

Pause playing background music.

void pauseEffect ( unsigned int  nSoundId)

Pause playing sound effect.

Parameters
nSoundIdThe return value of function playEffect
var pauseEffect ( var  nSoundId)

Pause playing sound effect.

Parameters
nSoundIdThe return value of function playEffect
local pauseEffect ( local  nSoundId)

Pause playing sound effect.

Parameters
nSoundIdThe return value of function playEffect
void playBackgroundMusic ( const char *  pszFilePath,
bool  bLoop 
)

Play background music.

Parameters
pszFilePathThe path of the background music file,or the FileName of T_SoundResInfo
bLoopWhether the background music loop or not
var playMusic ( var  pszFilePath,
var  bLoop 
)

Play background music.

Parameters
pszFilePathThe path of the background music file,or the FileName of T_SoundResInfo
bLoopWhether the background music loop or not
local playBackgroundMusic ( local  pszFilePath,
local  bLoop 
)

Play background music.

Parameters
pszFilePathThe path of the background music file,or the FileName of T_SoundResInfo
bLoopWhether the background music loop or not
void playBackgroundMusic ( const char *  pszFilePath)
inline
var playMusic ( var  pszFilePath)
inline
local playBackgroundMusic ( local  pszFilePath)
inline
unsigned int playEffect ( const char *  pszFilePath,
bool  bLoop 
)

Play sound effect.

Parameters
pszFilePathThe path of the effect file,or the FileName of T_SoundResInfo Whether to loop the effect playing, default value is false
var playEffect ( var  pszFilePath,
var  bLoop 
)

Play sound effect.

Parameters
pszFilePathThe path of the effect file,or the FileName of T_SoundResInfo Whether to loop the effect playing, default value is false
local playEffect ( local  pszFilePath,
local  bLoop 
)

Play sound effect.

Parameters
pszFilePathThe path of the effect file,or the FileName of T_SoundResInfo Whether to loop the effect playing, default value is false
unsigned int playEffect ( const char *  pszFilePath)
inline
var playEffect ( var  pszFilePath)
inline
local playEffect ( local  pszFilePath)
inline
void preloadBackgroundMusic ( const char *  pszFilePath)

Preload background music.

Parameters
pszFilePathThe path of the background music file,or the FileName of T_SoundResInfo
var preloadMusic ( var  pszFilePath)

Preload background music.

Parameters
pszFilePathThe path of the background music file,or the FileName of T_SoundResInfo
local preloadBackgroundMusic ( local  pszFilePath)

Preload background music.

Parameters
pszFilePathThe path of the background music file,or the FileName of T_SoundResInfo
void preloadEffect ( const char *  pszFilePath)

preload a compressed audio file

the compressed audio will be decode to wave, then write into an internal buffer in SimpleaudioEngine

var preloadEffect ( var  pszFilePath)

preload a compressed audio file

the compressed audio will be decode to wave, then write into an internal buffer in SimpleaudioEngine

local preloadEffect ( local  pszFilePath)

preload a compressed audio file

the compressed audio will be decode to wave, then write into an internal buffer in SimpleaudioEngine

void resumeAllEffects ( )

Resume all playing sound effect.

Parameters
nSoundIdThe return value of function playEffect
var resumeAllEffects ( )

Resume all playing sound effect.

Parameters
nSoundIdThe return value of function playEffect
local resumeAllEffects ( )

Resume all playing sound effect.

Parameters
nSoundIdThe return value of function playEffect
void resumeBackgroundMusic ( )

Resume playing background music.

var resumeMusic ( )

Resume playing background music.

local resumeBackgroundMusic ( )

Resume playing background music.

void resumeEffect ( unsigned int  nSoundId)

Resume playing sound effect.

Parameters
nSoundIdThe return value of function playEffect
var resumeEffect ( var  nSoundId)

Resume playing sound effect.

Parameters
nSoundIdThe return value of function playEffect
local resumeEffect ( local  nSoundId)

Resume playing sound effect.

Parameters
nSoundIdThe return value of function playEffect
void rewindBackgroundMusic ( )

Rewind playing background music.

var rewindMusic ( )

Rewind playing background music.

local rewindBackgroundMusic ( )

Rewind playing background music.

void setBackgroundMusicVolume ( float  volume)

set the volume of background music

Parameters
volumemust be in 0.0~1.0
var setMusicVolume ( var  volume)

set the volume of background music

Parameters
volumemust be in 0.0~1.0
local setBackgroundMusicVolume ( local  volume)

set the volume of background music

Parameters
volumemust be in 0.0~1.0
void setEffectsVolume ( float  volume)

set the volume of sound effecs

Parameters
volumemust be in 0.0~1.0
var setEffectsVolume ( var  volume)

set the volume of sound effecs

Parameters
volumemust be in 0.0~1.0
local setEffectsVolume ( local  volume)

set the volume of sound effecs

Parameters
volumemust be in 0.0~1.0
static SimpleAudioEngine*
sharedEngine
( )
static

Get the shared Engine object,it will new one when first time be called.

var getInstance ( )
static

Get the shared Engine object,it will new one when first time be called.

local sharedEngine ( )
static

Get the shared Engine object,it will new one when first time be called.

void stopAllEffects ( )

Stop all playing sound effects.

var stopAllEffects ( )

Stop all playing sound effects.

local stopAllEffects ( )

Stop all playing sound effects.

void stopBackgroundMusic ( bool  bReleaseData)

Stop playing background music.

Parameters
bReleaseDataIf release the background music data or not.As default value is false
var stopMusic ( var  bReleaseData)

Stop playing background music.

Parameters
bReleaseDataIf release the background music data or not.As default value is false
local stopBackgroundMusic ( local  bReleaseData)

Stop playing background music.

Parameters
bReleaseDataIf release the background music data or not.As default value is false
void stopBackgroundMusic ( )
inline
var stopMusic ( )
inline
local stopBackgroundMusic ( )
inline
void stopEffect ( unsigned int  nSoundId)

Stop playing sound effect.

Parameters
nSoundIdThe return value of function playEffect
var stopEffect ( var  nSoundId)

Stop playing sound effect.

Parameters
nSoundIdThe return value of function playEffect
local stopEffect ( local  nSoundId)

Stop playing sound effect.

Parameters
nSoundIdThe return value of function playEffect
void unloadEffect ( const char *  pszFilePath)

unload the preloaded effect from internal buffer

Parameters
[in]pszFilePathThe path of the effect file,or the FileName of T_SoundResInfo
var unloadEffect ( var  pszFilePath)

unload the preloaded effect from internal buffer

Parameters
[in]pszFilePathThe path of the effect file,or the FileName of T_SoundResInfo
local unloadEffect ( local  pszFilePath)

unload the preloaded effect from internal buffer

Parameters
[in]pszFilePathThe path of the effect file,or the FileName of T_SoundResInfo
bool willPlayBackgroundMusic ( )
var willPlayMusic ( )
local willPlayBackgroundMusic ( )

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