Class: SlideField::ObjectManager::Song

Inherits:
Base
  • Object
show all
Defined in:
lib/slidefield/objects/song.rb

Instance Method Summary collapse

Methods inherited from Base

#execute, #initialize, #method_missing, #on_draw

Constructor Details

This class inherits a constructor from SlideField::ObjectManager::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class SlideField::ObjectManager::Base

Instance Method Details

#on_activateObject



23
24
25
# File 'lib/slidefield/objects/song.rb', line 23

def on_activate
  @instance = @song.play @volume, 1, @loop
end

#on_deactivateObject



27
28
29
30
# File 'lib/slidefield/objects/song.rb', line 27

def on_deactivate
  @instance.stop
  @instance = nil
end

#on_loadObject



15
16
17
18
19
20
21
# File 'lib/slidefield/objects/song.rb', line 15

def on_load
  source = File.expand_path @obj.get(:source), @obj.include_path
  @loop = @obj.get(:loop)
  @volume = @obj.get(:volume) / 100.0

  @song = Gosu::Sample.new @window, source
end

#on_unloadObject



32
33
34
# File 'lib/slidefield/objects/song.rb', line 32

def on_unload
  @song = nil
end