Home Reference Source Test
public class | source

Animation

Extends:

UpdateableComponent → Animation

Animation component to be added to a GameObject to create animations inline with the global game loop. Animation Components currently only offer transform interpolation frames. Using buildInterpolation can be used to make custom animations which last n frames.

Constructor Summary

Public Constructor
public

Constructor for the animation component.

Member Summary

Public Members
public
public
public

Method Summary

Public Methods
public

Returns the frames left until all animations are complete.

public

buildInterpolation(key: string, frames: number, frameChange: function, finalFrame: function)

Adds an animation to the Animation component.

public

Clears an animation from executing any more frames.

public

Clear all animations on this Animation component.

public

interpolatePosition(posX: number, posY: number, posZ: number, frames: number, cycles: number, reset: boolean)

Wrapper function for creating animations of moving from one point to another (translating).

public

interpolateRotation(posX: number, posY: number, posZ: number, frames: number, cycles: number, reset: boolean)

Wrapper function for creating animations to rotate the GameObject.

public

interpolateScale(posX: number, posY: number, posZ: number, frames: number, cycles: number, reset: boolean)

Wrapper function for creating animations to change the scale of the GameObject.

public

isAnimating(interpol: string): *

Checks to see if an animation, defined by the interpol animation key, still has frames left to complete the animation.

public

onUpdate is called automatically as a Component.

Inherited Summary

From class Updateable
public
public
public
public

id: *

public

Cleanup code for when destroying an Updateable.

public

end()

Base call function for when this Updateable is to be ended.

public

onEnd()

Called when the object is being removed or cleaned up from usage.

public

Called when the object is intended to be paused.

public

Called when the the object is first introduced.

public

Called when the object is to be unpaused from paused state.

public

Called on every update within the game, once the object has had onStart called.

public

pause()

Base call function for when this Updateable is to be paused.

public

start()

Base call function for when this Updateable is to be started.

public

Base call function for when this Updateable is to be unpaused.

public

update()

Base call function for when this Updateable is to be updated.

From class Component
public
public
public

Called when the component is successfully added to a GameObject.

Public Constructors

public constructor() source

Constructor for the animation component. A GameObject may have more than one Animation component.

Override:

Component#constructor

Public Members

public animationFrames: number source

public className: string source

Override:

Component#className

public interpolationData: {} source

Public Methods

public animationFramesLeft(): * source

Returns the frames left until all animations are complete.

Return:

*

public buildInterpolation(key: string, frames: number, frameChange: function, finalFrame: function) source

Adds an animation to the Animation component. The animation component will keep track and trigger the animation frames once per game tick until there are no more frames left. On the final frame, the finalFrame callback will be called instead.

Params:

NameTypeAttributeDescription
key string

Animation interpolation key.

frames number

How many game ticks will this animation run.

frameChange function

Callback function executed once per animation frame.

finalFrame function

Callback function execured as the last frame. Defaults to frameChange.

public clearAnimation(key: string) source

Clears an animation from executing any more frames. The animation to remove is defined by the key parameter.

Params:

NameTypeAttributeDescription
key string

Animation interpolation key.

public clearAnimations() source

Clear all animations on this Animation component.

public interpolatePosition(posX: number, posY: number, posZ: number, frames: number, cycles: number, reset: boolean) source

Wrapper function for creating animations of moving from one point to another (translating).

Params:

NameTypeAttributeDescription
posX number

X position move per frame.

posY number

Y position move per frame.

posZ number

Z position move per frame.

frames number

Amount of frames in this animation.

cycles number

Amount of times to repeat this animation.

reset boolean

Reset the position on animation finish.

public interpolateRotation(posX: number, posY: number, posZ: number, frames: number, cycles: number, reset: boolean) source

Wrapper function for creating animations to rotate the GameObject.

Params:

NameTypeAttributeDescription
posX number

X scale change per frame.

posY number

Y scale change per frame.

posZ number

Z scale change per frame.

frames number

Amount of frames in this animation.

cycles number

Amount of times to repeat this animation.

reset boolean

Reset the position on animation finish.

public interpolateScale(posX: number, posY: number, posZ: number, frames: number, cycles: number, reset: boolean) source

Wrapper function for creating animations to change the scale of the GameObject.

Params:

NameTypeAttributeDescription
posX number

X scale change per frame.

posY number

Y scale change per frame.

posZ number

Z scale change per frame.

frames number

Amount of frames in this animation.

cycles number

Amount of times to repeat this animation.

reset boolean

Reset the position on animation finish.

public isAnimating(interpol: string): * source

Checks to see if an animation, defined by the interpol animation key, still has frames left to complete the animation.

Params:

NameTypeAttributeDescription
interpol string

Animation interpolation key.

Return:

*

public onUpdate() source

onUpdate is called automatically as a Component. Executes a frame for each animation.

Override:

Updateable#onUpdate