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
- #ext_music_fadeout(ms) ⇒ Object
- #ext_music_init(path) ⇒ Object
- #ext_music_pause ⇒ Object
- #ext_music_play ⇒ Object
- #ext_music_resume ⇒ Object
- #ext_music_stop ⇒ Object
- #fadeout(ms) ⇒ Object
-
#initialize(path) ⇒ Music
constructor
A new instance of Music.
- #pause ⇒ Object
- #play ⇒ Object
- #resume ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(path) ⇒ Music
Returns a new instance of Music.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ruby2d/music.rb', line 9 def initialize(path) unless RUBY_ENGINE == 'opal' unless File.exists? path raise Error, "Cannot find audio file `#{path}`" end end @path = path @loop = false ext_music_init(path) 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
#ext_music_fadeout(ms) ⇒ Object
252 253 254 |
# File 'ext/ruby2d/ruby2d-opal.rb', line 252 def ext_music_fadeout(ms) `S2D.FadeOutMusic(ms);` end |
#ext_music_init(path) ⇒ Object
232 233 234 |
# File 'ext/ruby2d/ruby2d-opal.rb', line 232 def ext_music_init(path) `#{self}.data = S2D.CreateMusic(path);` end |
#ext_music_pause ⇒ Object
240 241 242 |
# File 'ext/ruby2d/ruby2d-opal.rb', line 240 def ext_music_pause `S2D.PauseMusic();` end |
#ext_music_play ⇒ Object
236 237 238 |
# File 'ext/ruby2d/ruby2d-opal.rb', line 236 def ext_music_play `S2D.PlayMusic(#{self}.data, #{self}.loop);` end |
#ext_music_resume ⇒ Object
244 245 246 |
# File 'ext/ruby2d/ruby2d-opal.rb', line 244 def ext_music_resume `S2D.ResumeMusic();` end |
#ext_music_stop ⇒ Object
248 249 250 |
# File 'ext/ruby2d/ruby2d-opal.rb', line 248 def ext_music_stop `S2D.StopMusic();` end |
#fadeout(ms) ⇒ Object
38 39 40 |
# File 'lib/ruby2d/music.rb', line 38 def fadeout(ms) ext_music_fadeout(ms) end |
#pause ⇒ Object
26 27 28 |
# File 'lib/ruby2d/music.rb', line 26 def pause ext_music_pause end |
#play ⇒ Object
22 23 24 |
# File 'lib/ruby2d/music.rb', line 22 def play ext_music_play end |
#resume ⇒ Object
30 31 32 |
# File 'lib/ruby2d/music.rb', line 30 def resume ext_music_resume end |
#stop ⇒ Object
34 35 36 |
# File 'lib/ruby2d/music.rb', line 34 def stop ext_music_stop end |