diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/ruby2d/music.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/ruby2d/music.rb b/lib/ruby2d/music.rb index 41b8901..5974a8a 100644 --- a/lib/ruby2d/music.rb +++ b/lib/ruby2d/music.rb @@ -39,6 +39,22 @@ module Ruby2D ext_stop end + # Returns the previous volume setting, in percentage + def self.volume + self.ext_volume(-1) + end + + # Set music volume, 0 to 100% + def self.volume=(v) + # If a negative value, volume will be 0 + if v < 0 then v = 0 end + self.ext_volume(v) + end + + # Alias instance methods to class methods + def volume; Music.volume end + def volume=(v); Music.volume=(v) end + # Fade out music over provided milliseconds def fadeout(ms) ext_fadeout(ms) |
