Sound Functions

From X-Moto
Revision as of 13:42, 15 March 2008 by Nadenislamarre (talk | contribs) (PlayMusic("Music",v))
Jump to: navigation, search

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. 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