Kiwi.Components.Sound Class
The Sound Component is a class to assist with the creation and management of multiple pieces of audio that may exist on a single Entity. This class is NOT needed when dealing with audio but is instead can be used to assist in dealing with audio.
Constructor
Kiwi.Components.Sound
-
parent
Parameters:
-
parent
AnyWho the owner of the sound component is.
Returns:
Item Index
Methods
Methods
_validate
-
name
This method is used to check to see if an audio segment with the name that is specified is on this component.
Parameters:
-
name
StringThe name of the audio segment you want to check exists.
Returns:
addSound
-
name
-
key
-
[volume=1]
-
[loop=false]
Creates a new audio segment on this component.
Parameters:
-
name
StringThe name for this audio file. This is how you will access the audio from this component and so it should be unique.
-
key
StringThe piece of audio that you want to use.
-
[volume=1]
Number optionalThe volume that the audio should be set to.
-
[loop=false]
Boolean optionalIf the audio should keep play again when it finishes playing.
Returns:
destroy
()
public
Destroys this AudioComponent and all of the Audio objects it has.
getSound
-
name
Returns the Audio object for the sound that you pass.
Parameters:
-
name
StringThe piece of audio you would like to grab.
Returns:
objType
()
String
public
Returns the type of object that this is.
Returns:
"Sound"
play
-
name
Plays the audio that you specify.
Parameters:
-
name
StringThe name of the audio file you would like to play.
play
-
name
Stops the audio that you specify from playing.
Parameters:
-
name
StringName of the audio file you would like to stop.
play
-
name
Pauses the audio that you specify.
Parameters:
-
name
StringThe name of the audio you would like to pause.
play
-
name
Resumes the audio that you specify. Note: Audio can only resume if it was paused initially.
Parameters:
-
name
StringThe name of the audio you would like to resume.
postUpdate
()
public
Components can postUpdate, that is run an update after the parent has updated. This is to be overriden by subclasses.
preUpdate
()
public
Components can preUpdate, that is update before the parent updates. This is to be overriden by subclasses.
removeSound
-
name
Removes the audio sementment with the name you have given.
Parameters:
-
name
StringThe piece of audio you would like to remove.
update
()
public
If the component is being added to a State rather than a Game Object then over-ride its update method to perform required tasks.
Properties
active
Boolean
public
An active Component is one that has its update method called by its parent.
Default: true
dirty
Boolean
deprecated
public
The state of this component.
Default: false
name
String
public
The name of this component.
owner
Object
public
The object that owns this entity