Constructor
new Animator(parent)
| Name | Type | Description |
|---|---|---|
parent | Object | The object to animate |
- Source
mySprite = new gameify.Sprite(0, 0, new gameify.Image("player.png"));
let myAnimation = new gameify.Animation(frames, { duration: 200, loop: true });
mySprite.animator.set('idle', myAnimation);
mySprite.animator.play('idle');Members
animationProgress
The time the animation started playing
- Source
(readonly) animations
The animations currently assigned to the animator. Use Animator.set() and Animator.play() to add and play animations
- Source
(readonly) currentAnimation
The animation that is currently playing (or undefined if not playing). Use Animator.play() to change the current animation being played.
- Source
(readonly) currentAnimationName
The name of the current animation (or undefined if not). Use Animator.play() to change the current animation being played.
- Source
parent :Object
The object that this animator is attached to
- Object
- Source
playing
If an animation is currently playing
- Source
Methods
fromJSON(data, ref) → {gameify.Animation}
Creates a object from JSON data
| Name | Type | Description |
|---|---|---|
data | Object | | Serialized object data (from object.toJSON) |
ref | function | A function that returns a name for other objects, so they can be restored later |
- Source
- Type:
- gameify.
Animation
pause()
Pause the animation
- Source
play(name)
Play an animation, or resume it if it's paused. If the animation is paused or already playing, this function does not reset the animation (use Animator.stop() to reset the animation).
| Name | Type | Description |
|---|---|---|
name | String | The name of the animation |
- Source
resume()
Resume the animation
- Source
set(name, animation)
Add an animation to the animations list
| Name | Type | Description |
|---|---|---|
name | String | The name of the animation |
animation | gameify. | The animation |
- Source
stop()
Stop & reset the animation
- Source
toJSON(keyopt, ref) → {Object}
Convert the object to JSON
| Name | Type | Attributes | Description |
|---|---|---|---|
key | string | <optional> | Key object is stored under (unused, here for consistency with e.g. Date.toJSON, etc.) |
ref | function | A function that returns a name for other objects, so they can be restored later |
- Source
- Type:
- Object
update(delta)
Update the animation
| Name | Type | Description |
|---|---|---|
delta | Number | The time, in miliseconds, since the last frame |
- Source