mirror of
https://github.com/photonstorm/phaser
synced 2024-11-24 05:33:35 +00:00
Added support for beforeUpdate and afterUpdate world events
This commit is contained in:
parent
b0f2b833c8
commit
dbad873236
4 changed files with 52 additions and 0 deletions
|
@ -68,6 +68,18 @@ var World = new Class({
|
|||
{
|
||||
var localEvents = this.events;
|
||||
|
||||
MatterEvents.on(this.engine, 'beforeUpdate', function (event) {
|
||||
|
||||
localEvents.dispatch(new PhysicsEvent.BEFORE_UPDATE(event));
|
||||
|
||||
});
|
||||
|
||||
MatterEvents.on(this.engine, 'afterUpdate', function (event) {
|
||||
|
||||
localEvents.dispatch(new PhysicsEvent.AFTER_UPDATE(event));
|
||||
|
||||
});
|
||||
|
||||
MatterEvents.on(this.engine, 'collisionStart', function (event) {
|
||||
|
||||
localEvents.dispatch(new PhysicsEvent.COLLISION_START(event.pairs));
|
||||
|
|
19
v3/src/physics/matter-js/events/AfterUpdateEvent.js
Normal file
19
v3/src/physics/matter-js/events/AfterUpdateEvent.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
var Class = require('../../../utils/Class');
|
||||
var Event = require('../../../events/Event');
|
||||
|
||||
var AfterUpdateEvent = new Class({
|
||||
|
||||
Extends: Event,
|
||||
|
||||
initialize:
|
||||
|
||||
function AfterUpdateEvent (event)
|
||||
{
|
||||
Event.call(this, 'AFTER_UPDATE_EVENT');
|
||||
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = AfterUpdateEvent;
|
19
v3/src/physics/matter-js/events/BeforeUpdateEvent.js
Normal file
19
v3/src/physics/matter-js/events/BeforeUpdateEvent.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
var Class = require('../../../utils/Class');
|
||||
var Event = require('../../../events/Event');
|
||||
|
||||
var BeforeUpdateEvent = new Class({
|
||||
|
||||
Extends: Event,
|
||||
|
||||
initialize:
|
||||
|
||||
function BeforeUpdateEvent (event)
|
||||
{
|
||||
Event.call(this, 'BEFORE_UPDATE_EVENT');
|
||||
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = BeforeUpdateEvent;
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
module.exports = {
|
||||
|
||||
AFTER_UPDATE: require('./AfterUpdateEvent'),
|
||||
BEFORE_UPDATE: require('./BeforeUpdateEvent'),
|
||||
COLLISION_ACTIVE: require('./CollisionActiveEvent'),
|
||||
COLLISION_END: require('./CollisionEndEvent'),
|
||||
COLLISION_START: require('./CollisionStartEvent'),
|
||||
|
|
Loading…
Reference in a new issue