Game Development Reference
In-Depth Information
The Gideros Studio sound library is condensed into a couple of functions; these are enough to
achieve what we just discussed.
The first thing to note while playing sound with Gideros Studio is that there are two distinct objects:
the Sound object and the SoundChannel object. The Sound object provides the data that needs to be
played, whereas the SoundChannel object actually plays the sound.
local mySound = Sound.new("sound.wav")
local theChannel = mySound:play()
If you want to play a long track and perhaps loop through the file, you can also specify the point
from where you want the sound to start playing and whether you want to loop the sound.
is 0 by default, and loops defines how many times you want the sound to be looped.
loops value of 0 (the default) means that the sound will not be looped but just played once, 1 means
math.huge .
object. Here's an example of using the soundChannel object to manipulate the volume
Events
Like most frameworks, Gideros has an asynchronous way of processing things. Events are raised
when certain things happen—for example, when the user touches the screen, when the frame
is updated, and when system events occur (e.g., when the application starts, or is suspended,
resumed, or exited). Table 9-1 lists the events that are handled by Gideros Studio.
Table 9-1. Events Handled by Gideros Studio
Event Type
Events Handled
TOUCHES_BEGIN
TOUCHES_MOVE
TOUCHES_END
TOUCHES_CANCEL
Touch
ENTER_FRAME
ADDED_TO_STAGE
REMOVED_FROM_STAGE
( continued )
Frame and stage
 
Search WWH ::




Custom Search