Sound Functions
Contents
PlaySound("Sound",[v])
[require Xmoto >= 0.4.2]
Explanation
Using this function you can play a sound effect. The parameter 1 is the name of the sound, which is defined in the actually used theme file. Parameter 2 (v) is optional, and sets the Volume, in which the Sound shall be played. v is between 0 and 1 (0=>no sound, 1=> maximum sound, and for example, 0.5=>50% of the volume) In the following example, there must be 2 zones named "Zone0" and "Zone1". As soon as you enter the zone, the sound effect is played:
Script example
Zone0 = {} Zone1 = {} function Zone0.OnEnter() Game.PlaySound("ring"); end function Zone1.OnEnter() Game.PlaySound("ring",0.2); end
PlayMusic("Music")
[require Xmoto >= 0.4.2]
Explanation
Using this function you can play a music. The parameter 1 is the name of the musicd, which is defined in the actually used theme file. In the following example, there must be 3 zones named "Zone0", "Zone1" and "Zone2". As soon as you enter the zone, the music is played:
Script example
Zone0 = {} Zone1 = {} Zone2 = {} function Zone0.OnEnter() Game.PlayMusic("batcave"); end function Zone1.OnEnter() Game.StopMusic(); end function Zone2.OnEnter() Game.PlayMusic("madeirastew",0.5); end
StopMusic();
[require Xmoto >= 0.4.2]
Explanation
With this function you stop music playback for the current level.
Script example
Zone0 = {} Zone1 = {} function Zone0.OnEnter() Game.PlayMusic("batcave"); end function Zone1.OnEnter() Game.StopMusic(); end