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.

Public Class Methods


new (window, filename)

# File reference/gosu.rb, line 261
    def initialize(window, filename); end

Public Instance Methods


play (vol=1, speed=1, looping=false)

Plays the sample without panning.

Returns a SampleInstance.

volume:Can be anything from 0.0 (silence) to 1.0 (full volume).
speed:Playback speed is only limited by the underlying audio library, and can accept very high or low values. Use 1.0 for normal playback speed.
# File reference/gosu.rb, line 268
    def play(vol=1, speed=1, looping=false); end

play_pan (pan=0, vol=1, speed=1, looping=false)

Plays the sample with panning. Even if pan is 0.0, the sample will not be as loud as if it were played by calling play() due to the way the panning works.

Returns a SampleInstance.

volume:Can be anything from 0.0 (silence) to 1.0 (full volume).
speed:Playback speed is only limited by the underlying audio library, and can accept very high or low values. Use 1.0 for normal playback speed.
# File reference/gosu.rb, line 277
    def play_pan(pan=0, vol=1, speed=1, looping=false); end