Sound, Script and UI

Add Sound to Scene
Sound can be an interest part of a scene. In this lesson, you'll learn how to add a sound to a scene, and how to play a sound.
There are two ways for adding sound to scene:

1. In main menu, choose Create > Sound..., then select a sound file (.wav, .mid, .mp3, .wma, etc ) in file dialog that appears.

2. choose View > Sounds List..., then click New button in dialog that appears. Aside, click Delete button will remove selected sounds from scene.

Now, let's new a scene, and add two sounds from Awakening's sounds folder: buttonover.wav, whisper.mid.


Add Script to Scene
A Script is include some codes let you control scene. Script brings powerful and flexible control.
Like sound, there are two ways for adding script to scene:
In main menu, Create > Script... and View > Script List...

Now, let's open Script List Dialog, then new a String Script, named as "OnPlayButDown" (just click on name for rename), and input these code (see left picture):

if not IsPlayingMusic() then


Make Buttons
By use Overlay, you can design UI for scene. In this section, you'll learn how to make a button. 
1. Click the drop down arrow right at in main toolbar, select 'Image2D' in the popup menu. 

2. Then left click in viewport, you should see a white square, named as "play_0". Click again to create another, named as "play_1". 

3. Add two textures to scene: but_play_0.tga, but_play_1.tga. These files can be found at Awakeing's textures folder.  Then assign these two textures to Imge2D "play_0" and "play_1" respectively.
4: Align "play_0" and "play_1"( you can use in main toolbar ), then hide "play_1".


Assign Actions to Buttons
Select "play_0", then click "Add Action" button in "Command Target" sheet, a "Action Define" dialog will appears: 
Select Roll Over message, click Hide in Function List. "Object List" dialog will appears, select "play_0" ( please check "Hidden Object" for select "play_1"). Then click OK button in "Action Define" dialog, an Action will be added to "Actions List" of Command Target. Similarly, define other actions listed in right illustration. And similarly, add below actions to "play_1":

So what's these actions doing? When the mouse pointer rolls over the button, we hide "play_0" and show "play_1", so button will be light, also play a sound ( buttonover.wav ). When the mouse pointer rolls out the button, we hide "play_1" and show "play_0", so button will back normal. When the mouse left button is released while the pointer is over the button, we play a music (by do script OnPlayButDown).

The Awakening's Command System not just for make buttons, you can achieve various purpose if effectively use it.