API Docs for: 1.4.0
Show:

Kiwi.Components.Sound Class

Extends Kiwi.Component
Module: Components
Parent Module: Kiwi

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
)
Kiwi.Components.Sound

Parameters:

  • parent Any

    Who the owner of the sound component is.

Methods

_validate

(
  • name
)
Boolean private

This method is used to check to see if an audio segment with the name that is specified is on this component.

Parameters:

  • name String

    The name of the audio segment you want to check exists.

Returns:

Boolean:

addSound

(
  • name
  • key
  • [volume=1]
  • [loop=false]
)
Kiwi.Sound.Audio public

Creates a new audio segment on this component.

Parameters:

  • name String

    The name for this audio file. This is how you will access the audio from this component and so it should be unique.

  • key String

    The piece of audio that you want to use.

  • [volume=1] Number optional

    The volume that the audio should be set to.

  • [loop=false] Boolean optional

    If the audio should keep play again when it finishes playing.

Returns:

destroy

() public

Inherited from Kiwi.Component but overwritten in src\components\Sound.ts:174

Destroys this AudioComponent and all of the Audio objects it has.

getSound

(
  • name
)
Kiwi.Sound.Audio public

Returns the Audio object for the sound that you pass.

Parameters:

  • name String

    The piece of audio you would like to grab.

Returns:

objType

() String public

Inherited from Kiwi.Component but overwritten in src\components\Sound.ts:30

Returns the type of object that this is.

Returns:

String:

"Sound"

play

(
  • name
)
public

Plays the audio that you specify.

Parameters:

  • name String

    The name of the audio file you would like to play.

play

(
  • name
)
public

Stops the audio that you specify from playing.

Parameters:

  • name String

    Name of the audio file you would like to stop.

play

(
  • name
)
public

Pauses the audio that you specify.

Parameters:

  • name String

    The name of the audio you would like to pause.

play

(
  • name
)
public

Resumes the audio that you specify. Note: Audio can only resume if it was paused initially.

Parameters:

  • name String

    The 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
)
public

Removes the audio sementment with the name you have given.

Parameters:

  • name String

    The 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

game

Kiwi.Game public

The game this Component belongs to

name

String public

The name of this component.

owner

Object public

The object that owns this entity

state

Kiwi.State public

Inherited from Kiwi.Component: src\core\Component.ts:56

Available since 1.3.1

The state which this component's owner belongs to.