Class: TankSounds
- Defined in:
- lib/entities/components/tank_sounds.rb
Instance Attribute Summary
Attributes inherited from Component
Instance Method Summary collapse
- #collide ⇒ Object
-
#initialize(object, object_pool) ⇒ TankSounds
constructor
A new instance of TankSounds.
- #update ⇒ Object
Methods inherited from Component
Constructor Details
#initialize(object, object_pool) ⇒ TankSounds
Returns a new instance of TankSounds.
2 3 4 5 |
# File 'lib/entities/components/tank_sounds.rb', line 2 def initialize(object, object_pool) super(object) @object_pool = object_pool end |
Instance Method Details
#collide ⇒ Object
26 27 28 29 30 |
# File 'lib/entities/components/tank_sounds.rb', line 26 def collide vol, pan = Utils.volume_and_pan( object, @object_pool.camera) crash_sound.play(self.object_id, pan, vol, 1, false) end |
#update ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/entities/components/tank_sounds.rb', line 7 def update id = object.object_id if object.physics.moving? move_volume = Utils.volume( object, @object_pool.camera) pan = Utils.pan(object, @object_pool.camera) if driving_sound.paused?(id) driving_sound.resume(id) elsif driving_sound.stopped?(id) driving_sound.play(id, pan, 0.5, 1, true) end driving_sound.volume_and_pan(id, move_volume * 0.5, pan) else if driving_sound.(id) driving_sound.pause(id) end end end |