Module: Metro::HasAnimations

Included in:
Scene
Defined in:
lib/metro/animation/has_animations.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



6
7
8
# File 'lib/metro/animation/has_animations.rb', line 6

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#animate(actor_or_actor_name, options, &block) ⇒ Object Also known as: change

Define an animation from within another animation block, an event block or a method.

Examples:

Defining an animation that fades out the hero when they have

died.

  class HellScene
    draws :hero

    def update
      if hero.dead?
        animate :hero, to: { alpha: 0 }, interval: 60.ticks do
          transition_to :game_over
        end
      end
    end

  end


30
31
32
33
34
35
# File 'lib/metro/animation/has_animations.rb', line 30

def animate(actor_or_actor_name,options,&block)
  options[:actor] = actor(actor_or_actor_name)
  options[:context] = self
  animation_group = SceneAnimation.build options, &block
  enqueue animation_group
end