Arcade.Events.WORLD_STEP is a new event you can listen to. It is emitted by the Arcade Physics World every time the world steps once. It is emitted _after_ the bodies and colliders have been updated. Fix #4289

This commit is contained in:
Richard Davey 2019-06-19 15:41:45 +01:00
parent ef4b3cfe89
commit 6c575ca20e
4 changed files with 29 additions and 1 deletions

View file

@ -110,6 +110,7 @@ The following changes took place in the Pointer class:
* `Phaser.Sound.Events#DECODED_ALL` is a new event emitted by the Web Audio Sound Manager when it has finished decoding all of the audio data files passed to the `decodeAudio` method.
* `Phaser.Utils.Objects.Pick` is a new function that will take an object and an array of keys and return a new object containing just the keys provided in the array.
* `Text.align` and `Text.setAlign` can now accept `justify` as a type. It will apply basic justification to multi-line text, adding in extra spaces in order to justify the content. Fix #4291 (thanks @andrewbaranov @Donerkebap13 @dude78GH)
* `Arcade.Events.WORLD_STEP` is a new event you can listen to. It is emitted by the Arcade Physics World every time the world steps once. It is emitted _after_ the bodies and colliders have been updated. Fix #4289 (thanks @fant0m)
### Updates

View file

@ -901,6 +901,7 @@ var World = new Class({
*
* @method Phaser.Physics.Arcade.World#update
* @protected
* @fires Phaser.Physics.Arcade.Events#WORLD_STEP
* @since 3.0.0
*
* @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout.
@ -961,6 +962,8 @@ var World = new Class({
collider.update();
}
}
this.emit(Events.WORLD_STEP);
}
// Process any additional steps this frame
@ -976,6 +979,7 @@ var World = new Class({
* Advances the simulation by a time increment.
*
* @method Phaser.Physics.Arcade.World#step
* @fires Phaser.Physics.Arcade.Events#WORLD_STEP
* @since 3.10.0
*
* @param {number} delta - The delta time amount, in seconds, by which to advance the simulation.
@ -1018,6 +1022,8 @@ var World = new Class({
}
}
this.emit(Events.WORLD_STEP);
this.stepsLastFrame++;
},

View file

@ -0,0 +1,20 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2019 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Arcade Physics World Step Event.
*
* This event is dispatched by an Arcade Physics World instance whenever a physics step is run.
* It is emitted _after_ the bodies and colliders have been updated.
*
* In high framerate settings this can be multiple times per game frame.
*
* Listen to it from a Scene using: `this.physics.world.on('worldstep', listener)`.
*
* @event Phaser.Physics.Arcade.Events#WORLD_STEP
* @since 3.18.0
*/
module.exports = 'worldstep';

View file

@ -16,6 +16,7 @@ module.exports = {
RESUME: require('./RESUME_EVENT'),
TILE_COLLIDE: require('./TILE_COLLIDE_EVENT'),
TILE_OVERLAP: require('./TILE_OVERLAP_EVENT'),
WORLD_BOUNDS: require('./WORLD_BOUNDS_EVENT')
WORLD_BOUNDS: require('./WORLD_BOUNDS_EVENT'),
WORLD_STEP: require('./WORLD_STEP_EVENT')
};