This wiki has been moved to https://github.com/SuperTux/wiki into the mediawiki branch.

Difference between revisions of "ScriptingAmbientSound"

From SuperTux
Jump to: navigation, search
m (Bot-aided spell checker)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
  
= Summary =
+
== Summary ==
 
An ambient sound that was given a name can be controlled by scripts.
 
An ambient sound that was given a name can be controlled by scripts.
  
= Methods =
+
== Instance ==
 +
An <tt>AmbientSound</tt> is instantiated by placing a definition inside a level. It can then be accessed by its <tt>name</tt> from a script or via <tt>sector.<i>name</i></tt> from the console.
 +
 
 +
=== Example ===
 +
In the level file:
 +
<pre>
 +
(ambient_sound
 +
  (name "niagara")
 +
  (x 10)
 +
  (y 20)
 +
  (width 100)
 +
  (height 51)
 +
  (distance_factor 0.5)
 +
  (distance_bias 0)
 +
  (sample "waterfall.wav")
 +
  (volume 1)
 +
)
 +
</pre>
 +
 
 +
In a script:
 +
<pre>
 +
niagara.set_pos(0, 0);
 +
</pre>
 +
 
 +
In the console:
 +
<pre>
 +
sector.niagara.set_pos(18, 35)
 +
</pre>
 +
 
 +
== Methods ==
 
{| class="objectlist"
 
{| class="objectlist"
 
! class="method" style="vertical-align: top"| set_pos(float x, float y)
 
! class="method" style="vertical-align: top"| set_pos(float x, float y)
Line 16: Line 45:
 
|}
 
|}
  
= Constants =
+
== Constants ==
  
 
None
 
None
  
 
[[Category:Scripting Reference]]
 
[[Category:Scripting Reference]]

Revision as of 06:33, 25 June 2007


Summary

An ambient sound that was given a name can be controlled by scripts.

Instance

An AmbientSound is instantiated by placing a definition inside a level. It can then be accessed by its name from a script or via sector.name from the console.

Example

In the level file:

(ambient_sound
  (name "niagara")
  (x 10)
  (y 20)
  (width 100)
  (height 51)
  (distance_factor 0.5)
  (distance_bias 0)
  (sample "waterfall.wav")
  (volume 1)
)

In a script:

niagara.set_pos(0, 0);

In the console:

sector.niagara.set_pos(18, 35)

Methods

set_pos(float x, float y) Sets the position of the ambient sound
get_pos_x() Returns the x coordinate.
get_pos_y() Returns the y coordinate.

Constants

None