class Tsuku::Tweener

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/tsuku/tweener.rb, line 8
def initialize
  super
  
  @tweens = []
  @running = true
end

Public Instance Methods

add_tween(target, final_property_values, duration_ms, easing = :linear) click to toggle source
# File lib/tsuku/tweener.rb, line 15
def add_tween(target, final_property_values, duration_ms, easing = :linear)
  tween = Tween.new(target, final_property_values, duration_ms, easing)
  tween.start
  
  @tweens << tween

  tween
end
delete_tween(tween) click to toggle source
# File lib/tsuku/tweener.rb, line 24
def delete_tween(tween)
  tween.pause

  raise StandardError.new("Tween not found") unless @tweens.include?(tween)

  @tweens.delete(tween)

  @tweens
end
pause() click to toggle source
# File lib/tsuku/tweener.rb, line 46
def pause
  @running = false
end
resume() click to toggle source
# File lib/tsuku/tweener.rb, line 50
def resume
  @running = true
end
step(delta_ms) click to toggle source
# File lib/tsuku/tweener.rb, line 34
def step(delta_ms)
  return if !@running

  @tweens.reverse_each do |tween|
    tween.step(delta_ms)

    if tween.completed?
      @tweens.delete(tween)
    end
  end
end