Class: Ruby2D::Music
- Inherits:
-
Object
- Object
- Ruby2D::Music
- Defined in:
- lib/ruby2d/music.rb,
ext/ruby2d/ruby2d-opal.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#loop ⇒ Object
Returns the value of attribute loop.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #fadeout(ms) ⇒ Object
- #init(path) ⇒ Object
-
#initialize(path) ⇒ Music
constructor
A new instance of Music.
- #pause ⇒ Object
- #play ⇒ Object
- #resume ⇒ Object
- #stop ⇒ Object
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
#data ⇒ Object
Returns the value of attribute data.
6 7 8 |
# File 'lib/ruby2d/music.rb', line 6 def data @data end |
#loop ⇒ Object
Returns the value of attribute loop.
6 7 8 |
# File 'lib/ruby2d/music.rb', line 6 def loop @loop end |
#path ⇒ Object (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 |
#pause ⇒ Object
176 177 178 |
# File 'ext/ruby2d/ruby2d-opal.rb', line 176 def pause `S2D.PauseMusic();` end |
#play ⇒ Object
172 173 174 |
# File 'ext/ruby2d/ruby2d-opal.rb', line 172 def play `S2D.PlayMusic(#{self}.data, #{self}.loop);` end |
#resume ⇒ Object
180 181 182 |
# File 'ext/ruby2d/ruby2d-opal.rb', line 180 def resume `S2D.ResumeMusic();` end |
#stop ⇒ Object
184 185 186 |
# File 'ext/ruby2d/ruby2d-opal.rb', line 184 def stop `S2D.StopMusic();` end |