Class: Yuki::Animation::TimedAnimation

Inherits:
Object
  • Object
show all
Defined in:
docs/4_Systems_005_Animation.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



47
48
# File 'docs/4_Systems_005_Animation.rb', line 47

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)


35
36
37
# File 'docs/4_Systems_005_Animation.rb', line 35

def begin_time
  @begin_time
end

#end_timeTime? (readonly)

Get the end time of the animation (if started)

Returns:

  • (Time, nil)


38
39
40
# File 'docs/4_Systems_005_Animation.rb', line 38

def end_time
  @end_time
end

#parallel_animationsArray<TimedAnimation> (readonly)

Returns animation playing in parallel.

Returns:



27
28
29
# File 'docs/4_Systems_005_Animation.rb', line 27

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)



32
33
34
# File 'docs/4_Systems_005_Animation.rb', line 32

def root
  @root
end

#sub_animationTimedAnimation? (readonly)

Returns animation that plays after.

Returns:



29
30
31
# File 'docs/4_Systems_005_Animation.rb', line 29

def sub_animation
  @sub_animation
end

#time_source#call? (readonly)

Get the time source of the animation (if started)

Returns:

  • (#call, nil)


41
42
43
# File 'docs/4_Systems_005_Animation.rb', line 41

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)


56
57
# File 'docs/4_Systems_005_Animation.rb', line 56

def done?
end

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

Add this animation in parallel of another animation

Parameters:

Returns:



74
75
# File 'docs/4_Systems_005_Animation.rb', line 74

def in_parallel_of(other)
end

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

Add a parallel animation

Parameters:

Returns:

  • (self)


66
67
# File 'docs/4_Systems_005_Animation.rb', line 66

def parallel_add(other)
end

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

Add a sub animation

Parameters:

Returns:



80
81
# File 'docs/4_Systems_005_Animation.rb', line 80

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



85
86
# File 'docs/4_Systems_005_Animation.rb', line 85

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



51
52
# File 'docs/4_Systems_005_Animation.rb', line 51

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



61
62
# File 'docs/4_Systems_005_Animation.rb', line 61

def update
end