• ig.Animation

ig.

AnimationExtended

new AnimationExtended()

Enhanced animations.
- supports textures, i.e. tiling an animation tile across an entity
- adds a signal for when animation completes for improved sequencing

Author:
  • Collin Hover - collinhover.com
Source:

changed :Boolean

Whether animation has changed tiles since last update.

Default Value:
  • false
Source:

frameTime :Number

Time in seconds per frame of sequence.

Default Value:
  • 1
Source:

once :Boolean

Whether animation should only play once and then stop.

Default Value:
  • false
Source:

onCompleted :ig.Signal

Signal dispatched when animation completes.
- created on init.

Source:

opaqueOffset :Object

Size to offset from entity bounds for casting shadows when ig.EntityExtended#opaque. Tip: to set opaque offsets per animation, use ig.AnimationExtended#opaqueOffset

Source:
Example
// by default, shadow casting uses
// entity's opaque offsets
entity.opaqueOffset = {
     left: 0,
     right: 0,
     top: 0,
     bottom: 0
};
// unless the entity's current animation
// has its own opaque offsets
entity.currentAnim.opaqueOffset = {
     left: 0,
     right: 0,
     top: 0,
     bottom: 0
};
// opaque offsets can also be done per tile
entity.currentAnim.opaqueOffset = {
     tiles: {
        1: {
             left: 0,
             right: 0,
             top: 0,
             bottom: 0
         },
         2: {...}
     }
};

pivot :Vector2|Object

Pivot location, based on animation sheet.
- created on init

Default Value:
  • null
Source:

reverse :Boolean

Whether animation should play in reverse.

Default Value:
  • false
Source:

sequence :Array

Sequence of frames.
- created on init

Source:

stop :Boolean

Whether animation should be stopped initially.

Default Value:
  • false
Source:

textureHeight :Number

Size of textures, usually matching ig.AnimationExtended#texturing size.

Default Value:
  • 0
Source:

textureWidth :Number

Size of textures, usually matching ig.AnimationExtended#texturing size.

Default Value:
  • 0
Source:

<readonly> texturing :ig.EntityExtended

Entity being textured.

Source:

detexturize()

Removes textures, clearing all cached textures of this animation.

Source:

draw(targetX, targetY, scale, texturing)

Draws animation, accounting for scale and texturing target.

Parameters:
Name Type Argument Default Description
targetX Number
targetY Number
scale Number <optional>
1 scale to draw at
texturing ig.EntityExtended <optional>
optional entity to texture animation over.
Source:

getDuration() → {Number}

Source:
Returns:
{ Number } total duration of animation.

gotoFrame(f)

Moves animation to a frame.

Parameters:
Name Type Description
f Number frame number
Source:

init(sheet, settings)

Initializes animation.

Parameters:
Name Type Argument Description
sheet ig.AnimationSheet
settings Object <optional>
settings based on animation properties
Source:
See:
  • ig.Animation.

playFromStart(once, reverse)

Unstops and rewinds animation.

Parameters:
Name Type Argument Description
once Boolean <optional>
whether should play only once.
reverse Boolean <optional>
whether should play in reverse.
Source:

rewind(once, reverse)

Rewinds animation to start.

Parameters:
Name Type Argument Description
once Boolean <optional>
whether should play only once.
reverse Boolean <optional>
whether should play in reverse.
Source:
See:
  • ig.Animation.

texturize(entity)

Creates textures from animation that cover entity size.
- Adds 'textures' and 'texturedAnimCount' properties to textured entity. IMPORTANT: Textures are cached for performance using off-screen canvases.

Parameters:
Name Type Description
entity ig.EntityExtended entity base texture on.
Source:
Example
// entity is 64x64 size
entity.size.x = 64;
entity.size.y = 64;
// animation sheet tiles are 8x8 size
entity.animationSheet = new ig.AnimationSheet( "media/animation_sheet.png", 8, 8 );
// add some animations
entity.addAnim( 'idle', 1, [0] );
// entity animations should be textured
entity.textured = true;
// on next draw call
// textures will be created
// and cached

update()

Updates animation.

Source:
See:
  • ig.Animation.