Class: Ruby2D::Sound

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby2d/sound.rb

Instance Method Summary collapse

Constructor Details

#initialize(window, path) ⇒ Sound

Returns a new instance of Sound.



6
7
8
9
10
11
12
# File 'lib/ruby2d/sound.rb', line 6

def initialize(window, path)
  unless File.exists? path
    raise Error, "Cannot find sound file!"
  end
  window.create_audio(self, path)
  @window, @path = window, path
end

Instance Method Details

#playObject



14
15
16
# File 'lib/ruby2d/sound.rb', line 14

def play
  @window.play_audio(self)
end