Class: Phaser::Animation

Inherits:
Object
  • Object
show all
Includes:
Native
Defined in:
lib/opal/phaser/core/animation.rb

Overview

An Animation instance contains a single animation and the controls to play it. It is created by the AnimationManager, consists of Animation.Frame objects and belongs to a single Game Object such as a Sprite.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(game, parent, name, frameData, frames, frameRate = 60, _loop = false) ⇒ Animation

Returns a new instance of Animation.

Parameters:

  • game (Phaser.Game)

    A reference to the currently running game.

  • parent (Phaser.Sprite)

    A reference to the owner of this Animation.

  • name (String)

    The unique name for this animation, used in playback commands.

  • frame_data (Phaser.FrameData)

    The FrameData object that contains all frames used by this Animation.

  • frames (Array<Integer>, Array<String>)

    An array of numbers or strings indicating which frames to play in which order.

  • frame_rate (Integer)
    frameRate=60

    The speed at which the animation should play. The speed is given in frames per second.

  • loop (True, False)
    loop=false

    Whether or not the animation is looped or just plays once.



18
19
20
21
# File 'lib/opal/phaser/core/animation.rb', line 18

def initialize(game, parent, name, frameData, frames, frameRate = 60, _loop = false)
  @native_game = game
  @native = `new Phaser.Animation(#@native_game, parent, name, frameData, frames, frameRate, _loop)`
end

Instance Attribute Details

#nativeObject

Returns the value of attribute native.



9
10
11
# File 'lib/opal/phaser/core/animation.rb', line 9

def native
  @native
end