AnimationCore

Pixel.EXPORTS~ AnimationCore

Animation core class.

Constructor

new AnimationCore(parent)

Source:
Create new Animation Core element.
Parameters:
Name Type Description
parent Pixel.AnimatedSprite Parent of Animation Core.

Members

cache :Pixel.Sprite

Source:
Stores spritesheet.
Type:

current :boolean|Array.<Pixel.Sprite>

Source:
Current track being played.
Type:

frame :number

Source:
Current frame this core is on.
Type:
  • number

track :string

Source:
Current name of the track being played.
Type:
  • string

tracks :object

Source:
All tracks created that can be played.
Type:
  • object

Methods

add(name, prefix, delayopt)

Source:
Add track when cached spritesheet is defined through a json file.
Parameters:
Name Type Attributes Default Description
name string Name of track.
prefix string Name every item in track begins with.
delay number <optional>
0 How many items to skip before they are added.

create(data)

Source:
Create a new track if there is no json file.
Parameters:
Name Type Description
data object Data for the creation.
Properties
Name Type Description
name string Name of track.
positions Array.<number> Array of start and end id of animation.

multiAdd(groups)

Source:
Add multiple animation tracks at once (with json file).
Example
// Example of creating an animation, where sprite is Pixel.AnimatedSprite
data = { name: 'name', filter: 'prefix', offset: 'delay' }
sprite.animation.multiAdd([data]) // Adds just one, but you get the idea
Parameters:
Name Type Description
groups Array.<object> Data of every group to be added.

play(name)

Source:
Plays an animation saved in the cache.
Parameters:
Name Type Description
name string Name of track to be played.

stop(num)

Source:
Stops the current animation and plays 1 item in the cache on continous loop.
Parameters:
Name Type Description
num number ID of image being played continously.