Documentation

WHAT WE GOT

AABB
Physics Environment

Animation
Actions & Animations

Array
Support Classes

Audio
Sounds & Music

Audio Effect
Sounds & Music

Background Audio
Sounds & Music

Bezier
Actions & Animations

Blink
Actions & Animations

Body
Physics Environment

Callback
Actions & Animations

Chain Shape
Physics Environment

Circle Shape
Physics Environment

Color
Support Classes

Delay
Actions & Animations

Device
Support Classes

Director
Essentials

Ease
Actions & Animations

Edge Shape
Physics Environment

Event
Support Classes

Fade
Actions & Animations

Filter
Physics Environment

Fixture
Physics Environment

Jump
Actions & Animations

Label
User Interface

Layer
Essentials

Layer Color
Essentials

Liquid
Actions & Animations

Mass Data
Physics Environment

Menu
User Interface

Menu Image
User Interface

Menu Label
User Interface

Move
Actions & Animations

Numeric
Support Clases

Object Layer
Tiled Maps

Physics Sprite
Physics Environment

Place
Actions & Animations

Point
Support Classes

Polygon Shape
Physics Environment

Repeat
Actions & Animations

Rotate
Actions & Animations

Scale
Actions & Animations

Scene
Essentials

Screen
Support Classes

Sequence
Actions & Animations

Shape
Physics Environment

Shuffle
Actions & Animations

Size
Support Classes

Skew
Actions & Animations

Spawn
Actions & Animations

Split
Actions & Animations

Sprite
Essentials

Sprite Batch
Essentials

Sprite Frame Cache
Essentials

Tile Layer
Tiled Maps

Tile Map
Tiled Maps

Tile Set
Tiled Maps

Tint
Actions & Animations

Touch
Support Classes

Turn
Actions & Animations

Twirl
Actions & Animations

Visibility
Actions & Animations

Wave
Actions & Animations

Wiggle
Actions & Animations

World
Physics Environment

SOUNDS & MUSIC

Background Audio

The BackgroundAudio class supports the playback of background music for the Game Scenes. The Audio files are loaded into the instance using keys, which also are used to tell which audio must be played. The supporting file formats are: AAC, HE-ACC, AMR, ALAC, iLBC, IMA4, Linear PCM (Uncompressed), ยต-Law, a-Law and MP3.

Even if it has it's own volume, stop, and resume methods, they can be overridden by the Audio module mute and enable methods.

Watch out!

The simultaneous playback of multiple background audios is not supported, the play method will check for an existing playing audio and will stop it before it plays the new one. The playback of background music and sound effects is supported by mixing the BackgroundAudio and AudioEffect classes.

New

Returns a new instance of the BackgroundAudio class:

background_audio = BackgroundAudio.new

Add

Loads a new audio file with its identifier key:

background_audio.add(:deep_space, 'deep_space.mp3')

[]

Retrieves an audio using its identifier key:

background_audio[:deep_space]

[]=

Loads a new audio file with its identifier key:

background_audio[:deep_space] = 'deep_space.mp3'
More intel!

The []= and add method are equivalent.

Play

Plays the audio by its identifier key:

background_audio.play :deep_space

Options:

loop: - Boolean Optional
The Background Audio should play in a loop?

Stop

Stops the current audio playback:

background_audio.stop

Pause

Pauses the audio playback:

background_audio.pause

Resume

Resumes the audio playback if it has been paused:

background_audio.play :deep_space
background_audio.pause

background_audio.resume

Rewind

Restarts the audio playback from the beginning of the file:

background_audio.play :deep_space

background_audio.rewind

Playing?

Returns if the Background Audio instance is playing:

background_audio.playing?

Will Play?

Returns if the Background Audio will start the playback:

background_audio.will_play?

Volume

Gets and Sets the playback volume:

background_audio.volume = 0.5

p "The music volume is: #{background_audio.volume}"
More intel!

The playback volume range starts in 0.0 and ends in 1.0.