Sha256: c135150a83ab5ed2f15ef6755fbc488b47bab2ec12c83dc411f025afef554bf6
Contents?: true
Size: 1.53 KB
Versions: 2
Compression:
Stored size: 1.53 KB
Contents
module Joybox module Audio class AudioEffect attr_reader :effects def initialize @effects = Hash.new end def [](effect) @effects[effect] end def []=(effect, file_name) add effect: effect, file_name: file_name end def events @effects.keys end def add(options = {}) # Todo print error message on the console return unless [:effect, :file_name].all? { |k| options.has_key? k } @effects[options[:effect]] = options[:file_name] SimpleAudioEngine.sharedEngine.preloadEffect(options[:file_name]) end def play_defaults { pitch: 1.0, pan: 0.0, gain: 1.0 } end def play(effect, options = {}) options = options.nil? ? play_defaults : play_defaults.merge!(options) SimpleAudioEngine.sharedEngine.playEffect(@effects[effect], pitch: options[:pitch], pan: options[:pan], gain: options[:gain]) end def stop(audio_id) SimpleAudioEngine.sharedEngine.stopEffect(audio_id) end def remove(effect) SimpleAudioEngine.sharedEngine.unloadEffect(@effects[effect]) end def volume SimpleAudioEngine.sharedEngine.effectsVolume end def volume=(volume) SimpleAudioEngine.sharedEngine.setEffectsVolume(volume) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
joybox-1.1.1 | motion/joybox/audio/audio_effect.rb |
joybox-1.1.0 | motion/joybox/audio/audio_effect.rb |