Class: Yuki::Animation::Dim2Animation

Inherits:
TimedAnimation show all
Defined in:
scripts/01100 Yuki/00100 Animation/00100 Animation.rb

Overview

Class that perform a 2D animation (from point a to point b)

Instance Attribute Summary

Attributes inherited from TimedAnimation

#begin_time, #end_time, #parallel_animations, #root, #sub_animation, #time_source

Instance Method Summary collapse

Methods inherited from TimedAnimation

#done?, #in_parallel_of, #parallel_add, #play_before, #resolver=, #update

Constructor Details

#initialize(time_to_process, on, property, a_x, a_y, b_x, b_y, distortion: :UNICITY_DISTORTION, time_source: :GENERIC_TIME_SOURCE) ⇒ Dim2Animation

Create a new ScalarAnimation convert it to another number (between 0 & 1) in order to distord time

Parameters:

  • time_to_process (Float)

    number of seconds (with generic time) to process the animation

  • on (Object)

    object that will receive the property

  • property (Symbol)

    name of the property to affect (add the = sign in the symbol name)

  • a_x (Float, Symbol)

    origin x position

  • a_y (Float, Symbol)

    origin y position

  • b_x (Float, Symbol)

    destination x position

  • b_y (Float, Symbol)

    destination y position

  • distortion (#call, Symbol) (defaults to: :UNICITY_DISTORTION)

    callable taking one paramater (between 0 & 1) and

  • time_source (#call, Symbol) (defaults to: :GENERIC_TIME_SOURCE)

    callable taking no parameter and giving the current time



402
403
404
405
406
407
408
409
410
411
# File 'scripts/01100 Yuki/00100 Animation/00100 Animation.rb', line 402

def initialize(time_to_process, on, property, a_x, a_y, b_x, b_y, distortion: :UNICITY_DISTORTION,
               time_source: :GENERIC_TIME_SOURCE)
  super(time_to_process, distortion, time_source)
  @origin_x_param = a_x
  @origin_y_param = a_y
  @end_x = b_x
  @end_y = b_y
  @on_param = on
  @property = property
end

Instance Method Details

#start(begin_offset = 0)

Start the animation (initialize it)

Parameters:

  • begin_offset (Float) (defaults to: 0)

    offset that prevents the animation from starting before now + begin_offset seconds



415
416
417
418
419
420
421
422
# File 'scripts/01100 Yuki/00100 Animation/00100 Animation.rb', line 415

def start(begin_offset = 0)
  super
  @on = resolve(@on_param)
  @origin_x = resolve(@origin_x_param)
  @origin_y = resolve(@origin_y_param)
  @delta_x = resolve(@end_x) - @origin_x
  @delta_y = resolve(@end_y) - @origin_y
end