Class: Ruby2D::Music

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby2d/music.rb,
ext/ruby2d/ruby2d-opal.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Music



9
10
11
12
13
14
# File 'lib/ruby2d/music.rb', line 9

def initialize(path)
  # TODO: Check if file exists
  init(path)
  @path = path
  @loop = false
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



6
7
8
# File 'lib/ruby2d/music.rb', line 6

def data
  @data
end

#loopObject

Returns the value of attribute loop.



6
7
8
# File 'lib/ruby2d/music.rb', line 6

def loop
  @loop
end

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/ruby2d/music.rb', line 7

def path
  @path
end

Instance Method Details

#fadeout(ms) ⇒ Object



188
189
190
# File 'ext/ruby2d/ruby2d-opal.rb', line 188

def fadeout(ms)
  `S2D.FadeOutMusic(ms);`
end

#init(path) ⇒ Object



168
169
170
# File 'ext/ruby2d/ruby2d-opal.rb', line 168

def init(path)
  `#{self}.data = S2D.CreateMusic(path);`
end

#pauseObject



176
177
178
# File 'ext/ruby2d/ruby2d-opal.rb', line 176

def pause
  `S2D.PauseMusic();`
end

#playObject



172
173
174
# File 'ext/ruby2d/ruby2d-opal.rb', line 172

def play
  `S2D.PlayMusic(#{self}.data, #{self}.loop);`
end

#resumeObject



180
181
182
# File 'ext/ruby2d/ruby2d-opal.rb', line 180

def resume
  `S2D.ResumeMusic();`
end

#stopObject



184
185
186
# File 'ext/ruby2d/ruby2d-opal.rb', line 184

def stop
  `S2D.StopMusic();`
end