Class: TweenWrapper
Instance Method Summary collapse
- #cancel! ⇒ Object
- #done? ⇒ Boolean
-
#initialize(actor, property_targets, time, style) ⇒ TweenWrapper
constructor
A new instance of TweenWrapper.
- #update(time) ⇒ Object
Constructor Details
#initialize(actor, property_targets, time, style) ⇒ TweenWrapper
Returns a new instance of TweenWrapper.
3 4 5 6 7 8 9 10 |
# File 'lib/gamebox/core/tween_wrapper.rb', line 3 def initialize(actor, property_targets, time, style) @actor = actor @actor.when :remove_me, &method(:cancel!) @props = property_targets.keys initial_values = @props.map{|pr|actor.send(pr)} target_values = @props.map{|pr|property_targets[pr]} @tween = Tween.new(initial_values, target_values, style, time) end |
Instance Method Details
#cancel! ⇒ Object
20 21 22 |
# File 'lib/gamebox/core/tween_wrapper.rb', line 20 def cancel! @cancel = true end |
#done? ⇒ Boolean
24 25 26 |
# File 'lib/gamebox/core/tween_wrapper.rb', line 24 def done? @tween.done || @cancel end |
#update(time) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/gamebox/core/tween_wrapper.rb', line 12 def update(time) @tween.update time @props.each.with_index do |prop, i| # maybe use update_attributes instead? @actor.send("#{prop}=", @tween[i]) end end |