Sha256: fc16f4d1486098ab906b7ad418fc5cc3168b67a7f5231bb7ac84b5c23ab726a2

Contents?: true

Size: 703 Bytes

Versions: 4

Compression:

Stored size: 703 Bytes

Contents

require 'behavior'

class Audible < Behavior
  
  def setup
    @sound_manager = @actor.stage.sound_manager

    audible_obj = self
    @actor.instance_eval do
      (class << self; self; end).class_eval do
        define_method :play_sound do |*args|
          audible_obj.play_sound *args
        end
        define_method :stop_sound do |*args|
          audible_obj.stop_sound *args
        end
      end
  end


  end

  # Plays a sound via the SoundManager.  See SoundManager for
  # details on how to "define" sounds.
  def play_sound(*args)
    @sound_manager.play_sound *args
  end

  # Stops a sound via the SoundManager.
  def stop_sound(*args)
    @sound_manager.stop_sound *args
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gamebox-0.1.1 lib/gamebox/behaviors/audible.rb
gamebox-0.1.0 lib/gamebox/behaviors/audible.rb
gamebox-0.0.9 lib/gamebox/behaviors/audible.rb
gamebox-0.0.8 lib/gamebox/behaviors/audible.rb