mirror of
https://github.com/photonstorm/phaser
synced 2024-11-10 23:24:41 +00:00
Added Game Object level collision events
This commit is contained in:
parent
a7c644454f
commit
5cb7d8484f
1 changed files with 30 additions and 0 deletions
|
@ -22,6 +22,16 @@ var MatterCollisionEvents = {
|
|||
var bodyA = pair.bodyA;
|
||||
var bodyB = pair.bodyB;
|
||||
|
||||
if (bodyA.gameObject)
|
||||
{
|
||||
bodyA.gameObject.emit('collide', bodyA, bodyB, pair);
|
||||
}
|
||||
|
||||
if (bodyB.gameObject)
|
||||
{
|
||||
bodyB.gameObject.emit('collide', bodyB, bodyA, pair);
|
||||
}
|
||||
|
||||
matter.Events.trigger(bodyA, 'onCollide', { pair: pair });
|
||||
matter.Events.trigger(bodyB, 'onCollide', { pair: pair });
|
||||
|
||||
|
@ -54,6 +64,16 @@ var MatterCollisionEvents = {
|
|||
var bodyA = pair.bodyA;
|
||||
var bodyB = pair.bodyB;
|
||||
|
||||
if (bodyA.gameObject)
|
||||
{
|
||||
bodyA.gameObject.emit('collideActive', bodyA, bodyB, pair);
|
||||
}
|
||||
|
||||
if (bodyB.gameObject)
|
||||
{
|
||||
bodyB.gameObject.emit('collideActive', bodyB, bodyA, pair);
|
||||
}
|
||||
|
||||
matter.Events.trigger(bodyA, 'onCollideActive', { pair: pair });
|
||||
matter.Events.trigger(bodyB, 'onCollideActive', { pair: pair });
|
||||
|
||||
|
@ -76,6 +96,16 @@ var MatterCollisionEvents = {
|
|||
var bodyA = pair.bodyA;
|
||||
var bodyB = pair.bodyB;
|
||||
|
||||
if (bodyA.gameObject)
|
||||
{
|
||||
bodyA.gameObject.emit('collideEnd', bodyA, bodyB, pair);
|
||||
}
|
||||
|
||||
if (bodyB.gameObject)
|
||||
{
|
||||
bodyB.gameObject.emit('collideEnd', bodyB, bodyA, pair);
|
||||
}
|
||||
|
||||
matter.Events.trigger(bodyA, 'onCollideEnd', { pair: pair });
|
||||
matter.Events.trigger(bodyB, 'onCollideEnd', { pair: pair });
|
||||
|
||||
|
|
Loading…
Reference in a new issue