Skip to content

Commit 15c6e77

Browse files
committed
New Animation events
1 parent 28c6635 commit 15c6e77

5 files changed

Lines changed: 97 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* @author Richard Davey <rich@photonstorm.com>
3+
* @copyright 2020 Photon Storm Ltd.
4+
* @license {@link https://opensource.org/licenses/MIT|MIT License}
5+
*/
6+
7+
/**
8+
* The Animation Stop Event.
9+
*
10+
* This event is dispatched by an Animation instance when playback is forcibly stopped on it,
11+
* i.e. `Sprite.stop()`, or similar, is called. Or, a new animation is started before the
12+
* previous one completes.
13+
*
14+
* @event Phaser.Animations.Events#ANIMATION_STOP
15+
* @since 3.50.0
16+
*
17+
* @param {Phaser.Animations.Animation} animation - A reference to the Animation that was stopped.
18+
* @param {Phaser.Animations.AnimationFrame} frame - The current Animation Frame that the Animation stopped on.
19+
* @param {Phaser.GameObjects.Sprite} gameObject - A reference to the Game Object on which the animation stopped.
20+
*/
21+
module.exports = 'stop';
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* @author Richard Davey <rich@photonstorm.com>
3+
* @copyright 2020 Photon Storm Ltd.
4+
* @license {@link https://opensource.org/licenses/MIT|MIT License}
5+
*/
6+
7+
/**
8+
* The Animation Update Event.
9+
*
10+
* This event is dispatched by an animation when it updates. This happens when the animation changes frame,
11+
* based on the animation frame rate and other factors like `timeScale` and `delay`.
12+
*
13+
* Listen for it on the Animation using `anim.on('update', listener)`
14+
*
15+
* @event Phaser.Animations.Events#ANIMATION_UPDATE
16+
* @since 3.50.0
17+
*
18+
* @param {Phaser.Animations.Animation} animation - A reference to the Animation that has updated on the Sprite.
19+
* @param {Phaser.Animations.AnimationFrame} frame - The current Animation Frame of the Animation.
20+
* @param {Phaser.GameObjects.Sprite} gameObject - A reference to the Game Object on which the animation updated.
21+
*/
22+
module.exports = 'update';
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* @author Richard Davey <rich@photonstorm.com>
3+
* @copyright 2020 Photon Storm Ltd.
4+
* @license {@link https://opensource.org/licenses/MIT|MIT License}
5+
*/
6+
7+
/**
8+
* The Sprite Animation Key Complete Event.
9+
*
10+
* This event is dispatched by a Sprite when animation playback is forcibly stopped on it,
11+
* i.e. `Sprite.stop()`, or similar, is called. Or, a new animation is started before the
12+
* previous one completes.
13+
*
14+
* Listen for it on the Sprite using `sprite.on('animationstop-key', listener)` where `key` is the key of
15+
* the animation. For example, if you had an animation with the key 'explode' you should listen for `animationstop-explode`.
16+
*
17+
* @event Phaser.Animations.Events#SPRITE_ANIMATION_KEY_STOP
18+
* @since 3.50.0
19+
*
20+
* @param {Phaser.Animations.Animation} animation - A reference to the Animation that was stopped.
21+
* @param {Phaser.Animations.AnimationFrame} frame - The current Animation Frame that the Animation stopped on.
22+
* @param {Phaser.GameObjects.Sprite} gameObject - A reference to the Game Object on which the animation stopped.
23+
*/
24+
module.exports = 'animationstop-';
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* @author Richard Davey <rich@photonstorm.com>
3+
* @copyright 2020 Photon Storm Ltd.
4+
* @license {@link https://opensource.org/licenses/MIT|MIT License}
5+
*/
6+
7+
/**
8+
* The Sprite Animation Stop Event.
9+
*
10+
* This event is dispatched by a Sprite when animation playback is forcibly stopped on it,
11+
* i.e. `Sprite.stop()`, or similar, is called. Or, a new animation is started before the
12+
* previous one completes.
13+
*
14+
* Listen for it on the Sprite using `sprite.on('animationstop', listener)`
15+
*
16+
* This same event is dispatched for all animations. To listen for a specific animation,
17+
* use the `SPRITE_ANIMATION_KEY_STOP` event.
18+
*
19+
* @event Phaser.Animations.Events#SPRITE_ANIMATION_STOP
20+
* @since 3.50.0
21+
*
22+
* @param {Phaser.Animations.Animation} animation - A reference to the Animation that was stopped.
23+
* @param {Phaser.Animations.AnimationFrame} frame - The current Animation Frame that the Animation stopped on.
24+
* @param {Phaser.GameObjects.Sprite} gameObject - A reference to the Game Object on which the animation stopped.
25+
*/
26+
module.exports = 'animationstop';

src/animations/events/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ module.exports = {
1515
ANIMATION_REPEAT: require('./ANIMATION_REPEAT_EVENT'),
1616
ANIMATION_RESTART: require('./ANIMATION_RESTART_EVENT'),
1717
ANIMATION_START: require('./ANIMATION_START_EVENT'),
18+
ANIMATION_STOP: require('./ANIMATION_STOP_EVENT'),
19+
ANIMATION_UPDATE: require('./ANIMATION_UPDATE_EVENT'),
1820
PAUSE_ALL: require('./PAUSE_ALL_EVENT'),
1921
REMOVE_ANIMATION: require('./REMOVE_ANIMATION_EVENT'),
2022
RESUME_ALL: require('./RESUME_ALL_EVENT'),
@@ -23,10 +25,12 @@ module.exports = {
2325
SPRITE_ANIMATION_KEY_REPEAT: require('./SPRITE_ANIMATION_KEY_REPEAT_EVENT'),
2426
SPRITE_ANIMATION_KEY_RESTART: require('./SPRITE_ANIMATION_KEY_RESTART_EVENT'),
2527
SPRITE_ANIMATION_KEY_START: require('./SPRITE_ANIMATION_KEY_START_EVENT'),
28+
SPRITE_ANIMATION_KEY_STOP: require('./SPRITE_ANIMATION_KEY_STOP_EVENT'),
2629
SPRITE_ANIMATION_KEY_UPDATE: require('./SPRITE_ANIMATION_KEY_UPDATE_EVENT'),
2730
SPRITE_ANIMATION_REPEAT: require('./SPRITE_ANIMATION_REPEAT_EVENT'),
2831
SPRITE_ANIMATION_RESTART: require('./SPRITE_ANIMATION_RESTART_EVENT'),
2932
SPRITE_ANIMATION_START: require('./SPRITE_ANIMATION_START_EVENT'),
33+
SPRITE_ANIMATION_STOP: require('./SPRITE_ANIMATION_STOP_EVENT'),
3034
SPRITE_ANIMATION_UPDATE: require('./SPRITE_ANIMATION_UPDATE_EVENT')
3135

3236
};

0 commit comments

Comments
 (0)