Class: Gosu::Sample

Inherits:
Object
  • Object
show all
Defined in:
rdoc/gosu.rb

Overview

A sample is a short sound that is completely loaded in memory, can be played multiple times at once and offers very flexible playback parameters. Use samples for everything that's not music.

See Also:

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Sample #initialize(window, filename) ⇒ Sample

Loads a sample from a file.

(Passing a Window reference is not necessary anymore, please use the first overload from now on.)

Parameters:

  • filename (String)

    the path to load the sample from.


526
# File 'rdoc/gosu.rb', line 526

def initialize(filename); end

Instance Method Details

#play(volume = 1, speed = 1, looping = false) ⇒ Channel

Plays the sample without panning.

Parameters:

  • volume (Float) (defaults to: 1)
  • speed (Float) (defaults to: 1)
  • looping (true, false) (defaults to: false)

    whether the sample should play in a loop. If you pass true, be sure to store the return value of this method so that you can later stop the looping sound.

Returns:

See Also:


537
# File 'rdoc/gosu.rb', line 537

def play(volume=1, speed=1, looping=false); end

#play_pan(pan = 0, volume = 1, speed = 1, looping = false) ⇒ Channel

Plays the sample with panning.

Parameters:

  • pan (Float) (defaults to: 0)
  • volume (Float) (defaults to: 1)
  • speed (Float) (defaults to: 1)
  • looping (true, false) (defaults to: false)

    whether the sample should play in a loop. If you pass true, be sure to store the return value of this method so that you can later stop the looping sound.

Returns:

See Also:


549
# File 'rdoc/gosu.rb', line 549

def play_pan(pan=0, volume=1, speed=1, looping=false); end