Class: TweenManager

Inherits:
Object show all
Defined in:
lib/gamebox/core/tween_manager.rb

Instance Method Summary collapse

Constructor Details

#initializeTweenManager

Returns a new instance of TweenManager.



4
5
6
7
# File 'lib/gamebox/core/tween_manager.rb', line 4

def initialize
  @tweens = []
  director.when :update, &method(:update)
end

Instance Method Details

#tween_properties(actor, properties, time, tween_style = Tween::Linear) ⇒ Object



9
10
11
12
13
14
# File 'lib/gamebox/core/tween_manager.rb', line 9

def tween_properties(actor, properties, time, tween_style=Tween::Linear)
  tween = TweenWrapper.new(actor, properties, time, tween_style)
  @tweens << tween
  # return it so we can cancel it
  tween
end

#update(time, time_in_secs) ⇒ Object



16
17
18
19
20
21
# File 'lib/gamebox/core/tween_manager.rb', line 16

def update(time, time_in_secs)
  @tweens.each do |tween|
    tween.update time unless tween.done?
  end
  @tweens.reject! &:done?
end