class AdventureRL::AudioPlayer
Constants
- DEFAULT_SETTINGS
Default settings for
AudioPlayer
. Are superseded by settings passed to new.
Public Class Methods
new(settings = {})
click to toggle source
Pass settings Hash or Settings
as argument. Supersedes DEFAULT_SETTINGS
.
Calls superclass method
# File lib/AdventureRL/AudioPlayer.rb, line 13 def initialize settings = {} super end
Public Instance Methods
update()
click to toggle source
Overwrite FileGroupPlayer#update
to set a max speed limit. Don't play anymore once it it greater than the max speed. :max_speed
can be passed to new, to overwrite the default.
Calls superclass method
# File lib/AdventureRL/AudioPlayer.rb, line 26 def update return if (above_max_speed?) super end
Private Instance Methods
above_max_speed?()
click to toggle source
Returns true if the current playback speed is above the max speed limit.
# File lib/AdventureRL/AudioPlayer.rb, line 35 def above_max_speed? return get_speed > get_settings(:max_speed) end
get_default_settings()
click to toggle source
Returns this class' DEFAULT_SETTINGS
.
# File lib/AdventureRL/AudioPlayer.rb, line 53 def get_default_settings return DEFAULT_SETTINGS end
load_file(file)
click to toggle source
(Stops the last audio file,) – Gosu cannot stop a Gosu::Sample, and that's what we're using.
Loads the new audio file file
, and play it right away.
# File lib/AdventureRL/AudioPlayer.rb, line 42 def load_file file get_current_channel.stop if (get_current_channel) sample = Gosu::Sample.new(file) set_current_channel sample.play( get_audio.get_settings(:volume), @speed, !:loop ) end