Animation
Extends:
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 |
animationFramesLeft(): * 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 |
clearAnimation(key: string) 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() onUpdate is called automatically as a Component. |
Inherited Summary
From class Updateable | ||
public |
deregister: * |
|
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 |
onPause() Called when the object is intended to be paused. |
|
public |
onStart() Called when the the object is first introduced. |
|
public |
Called when the object is to be unpaused from paused state. |
|
public |
onUpdate() 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 |
unpause() 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 |
isUnique: * |
|
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#constructorPublic Members
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:
Name | Type | Attribute | Description |
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:
Name | Type | Attribute | Description |
key | string | Animation interpolation key. |
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:
Name | Type | Attribute | Description |
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:
Name | Type | Attribute | Description |
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:
Name | Type | Attribute | Description |
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:
Name | Type | Attribute | Description |
interpol | string | Animation interpolation key. |
Return:
* |
public onUpdate() source
onUpdate is called automatically as a Component. Executes a frame for each animation.