class Core::Sample
cache system borks inheritance, so we need to wrap a Gosu::Sample instance
Attributes
file[R]
Public Class Methods
new(file)
click to toggle source
# File lib/sample.rb, line 7 def initialize(file) @file = file if @@cache[file] @sample = @@cache[file] return end begin @sample = Gosu::Sample.new("#{Core::LIBRARY_PATH}/sounds/#{file}.wav") @@cache.store(file, @sample) rescue RuntimeError puts("ERROR: Failed to open sound #{file}") return end end
Public Instance Methods
play(vol=1.0, speed=1, looping=false)
click to toggle source
# File lib/sample.rb, line 24 def play(vol=1.0, speed=1, looping=false) vol *= Core.config[:volume] @sample.play(vol, speed, looping) end
sample()
click to toggle source
# File lib/sample.rb, line 21 def sample return @sample end