Class: Yuki::Animation::TimedAnimation

Inherits:
Object
  • Object
show all
Defined in:
docs/01500_Yuki.rb

Overview

Class calculating time offset for animation.

This class also manage parallel & sub animation. Example :

(TimedAnimation.new(1) | TimedAnimation.new(2) > TimedAnimation.new(3)).root
# Is equivalent to
TimedAnimation.new(1).parallel_play(TimedAnimation.new(2)).play_before(TimedAnimation.new(3)).root
# Which is equivalent to : play 1 & 2 in parallel and then play 3
# Note that if 2 has sub animation, its sub animation has to finish in order to see animation 3

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(time_to_process, distortion = :UNICITY_DISTORTION, time_source = :GENERIC_TIME_SOURCE) ⇒ TimedAnimation

Create a new TimedAnimation

Parameters:

  • time_to_process (Float)

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

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

    callable taking one paramater (between 0 & 1) and convert it to another number (between 0 & 1) in order to distord time

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

    callable taking no parameter and giving the current time



1018
1019
# File 'docs/01500_Yuki.rb', line 1018

def initialize(time_to_process, distortion = :UNICITY_DISTORTION, time_source = :GENERIC_TIME_SOURCE)
end

Instance Attribute Details

#begin_timeTime? (readonly)

Get the begin time of the animation (if started)

Returns:

  • (Time, nil)


1006
1007
1008
# File 'docs/01500_Yuki.rb', line 1006

def begin_time
  @begin_time
end

#end_timeTime? (readonly)

Get the end time of the animation (if started)

Returns:

  • (Time, nil)


1009
1010
1011
# File 'docs/01500_Yuki.rb', line 1009

def end_time
  @end_time
end

#parallel_animationsArray<TimedAnimation> (readonly)

Returns animation playing in parallel.

Returns:



998
999
1000
# File 'docs/01500_Yuki.rb', line 998

def parallel_animations
  @parallel_animations
end

#rootTimedAnimation

Returns the root animation (to retreive the right animation to play when building animation using operators).

Returns:

  • (TimedAnimation)

    the root animation (to retreive the right animation to play when building animation using operators)



1003
1004
1005
# File 'docs/01500_Yuki.rb', line 1003

def root
  @root
end

#sub_animationTimedAnimation? (readonly)

Returns animation that plays after.

Returns:



1000
1001
1002
# File 'docs/01500_Yuki.rb', line 1000

def sub_animation
  @sub_animation
end

#time_source#call? (readonly)

Get the time source of the animation (if started)

Returns:

  • (#call, nil)


1012
1013
1014
# File 'docs/01500_Yuki.rb', line 1012

def time_source
  @time_source
end

Instance Method Details

#done?Boolean

Note:

should always be called after start

Indicate if the animation is done

Returns:

  • (Boolean)


1027
1028
# File 'docs/01500_Yuki.rb', line 1027

def done?
end

#in_parallel_of(other) ⇒ TimedAnimation Also known as: >>

Add this animation in parallel of another animation

Parameters:

Returns:



1045
1046
# File 'docs/01500_Yuki.rb', line 1045

def in_parallel_of(other)
end

#parallel_add(other) ⇒ self Also known as: <<, |, parallel_play

Add a parallel animation

Parameters:

Returns:

  • (self)


1037
1038
# File 'docs/01500_Yuki.rb', line 1037

def parallel_add(other)
end

#play_before(other) ⇒ TimedAnimation Also known as: >

Add a sub animation

Parameters:

Returns:



1051
1052
# File 'docs/01500_Yuki.rb', line 1051

def play_before(other)
end

#resolver=(resolver)

Define the resolver (and transmit it to all the childs / parallel)

Parameters:

  • resolver (#call)

    callable that takes 1 parameter and return an object



1056
1057
# File 'docs/01500_Yuki.rb', line 1056

def resolver=(resolver)
end

#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



1022
1023
# File 'docs/01500_Yuki.rb', line 1022

def start(begin_offset = 0)
end

#update

Note:

should always be called after start

Update the animation internal time and call update_internal with a parameter between 0 & 1 indicating the progression of the animation



1032
1033
# File 'docs/01500_Yuki.rb', line 1032

def update
end