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.



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

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:



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

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:



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

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