Module: Moon::TransitionHost

Included in:
Transitionable
Defined in:
lib/moon/packages/std/mixins/transition_host.rb

Instance Method Summary collapse

Instance Method Details

#add_transition(src, dest, duration, easer = Easing::Linear, &block) ⇒ Transition

Parameters:

Returns:


7
8
9
10
11
# File 'lib/moon/packages/std/mixins/transition_host.rb', line 7

def add_transition(src, dest, duration, easer = Easing::Linear, &block)
  transition = Transition.new(src, dest, duration, easer, &block)
  (@transitions ||= []).push transition
  transition
end

#finish_transitionsVoid

Force all transitions to finish.

Returns:

  • (Void)

42
43
44
45
# File 'lib/moon/packages/std/mixins/transition_host.rb', line 42

def finish_transitions
  return unless @transitions
  @transitions.each(&:finish)
end

#remove_transition(transition) ⇒ void

This method returns an undefined value.

Parameters:


15
16
17
18
# File 'lib/moon/packages/std/mixins/transition_host.rb', line 15

def remove_transition(transition)
  return unless @transitions
  @transitions.delete transition
end

#remove_transitions(transitions) ⇒ void

This method returns an undefined value.

Parameters:


22
23
24
# File 'lib/moon/packages/std/mixins/transition_host.rb', line 22

def remove_transitions(transitions)
  @transitions -= transitions
end

#update_transitions(delta) ⇒ Object

Parameters:


27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/moon/packages/std/mixins/transition_host.rb', line 27

def update_transitions(delta)
  return unless @transitions
  return if @transitions.empty?
  dead = []
  @transitions.each do |transition|
    transition.update delta
    dead << transition if transition.done?
  end
  unless dead.empty?
    remove_transitions dead
  end
end