@@ -11,6 +11,7 @@ var Collider = require('./Collider');
1111var CONST = require ( './const' ) ;
1212var DistanceBetween = require ( '../../math/distance/DistanceBetween' ) ;
1313var EventEmitter = require ( 'eventemitter3' ) ;
14+ var Events = require ( './events' ) ;
1415var FuzzyEqual = require ( '../../math/fuzzy/Equal' ) ;
1516var FuzzyGreaterThan = require ( '../../math/fuzzy/GreaterThan' ) ;
1617var FuzzyLessThan = require ( '../../math/fuzzy/LessThan' ) ;
@@ -31,50 +32,6 @@ var TransformMatrix = require('../../gameobjects/components/TransformMatrix');
3132var Vector2 = require ( '../../math/Vector2' ) ;
3233var Wrap = require ( '../../math/Wrap' ) ;
3334
34- /**
35- * The physics simulation paused.
36- * @event Phaser.Physics.Arcade.World#pauseEvent
37- */
38-
39- /**
40- * The physics simulation resumed (from a paused state).
41- * @event Phaser.Physics.Arcade.World#resumeEvent
42- */
43-
44- /**
45- * Two Game Objects collided.
46- * This event is emitted only if at least one body has `onCollide` enabled.
47- * @event Phaser.Physics.Arcade.World#collideEvent
48- * @param {Phaser.GameObjects.GameObject } gameObject1
49- * @param {Phaser.GameObjects.GameObject } gameObject2
50- * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody } body1
51- * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody } body2
52- * @see Phaser.Physics.Arcade.Body#onCollide
53- */
54-
55- /**
56- * Two Game Objects overlapped.
57- * This event is emitted only if at least one body has `onOverlap` enabled.
58- * @event Phaser.Physics.Arcade.World#overlapEvent
59- * @param {Phaser.GameObjects.GameObject } gameObject1
60- * @param {Phaser.GameObjects.GameObject } gameObject2
61- * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody } body1
62- * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody } body2
63- * @see Phaser.Physics.Arcade.Body#onOverlap
64- */
65-
66- /**
67- * A Body contacted the world boundary.
68- * This event is emitted only if the body has `onWorldBounds` enabled.
69- * @event Phaser.Physics.Arcade.World#worldboundsEvent
70- * @param {Phaser.Physics.Arcade.Body } body
71- * @param {boolean } up
72- * @param {boolean } down
73- * @param {boolean } left
74- * @param {boolean } right
75- * @see Phaser.Physics.Arcade.Body#onWorldBounds
76- */
77-
7835/**
7936 * @typedef {object } ArcadeWorldConfig
8037 *
@@ -864,7 +821,7 @@ var World = new Class({
864821 * checks.
865822 *
866823 * @method Phaser.Physics.Arcade.World#pause
867- * @fires Phaser.Physics.Arcade.World#pauseEvent
824+ * @fires Phaser.Physics.Arcade.Events#PAUSE
868825 * @since 3.0.0
869826 *
870827 * @return {Phaser.Physics.Arcade.World } This World object.
@@ -873,7 +830,7 @@ var World = new Class({
873830 {
874831 this . isPaused = true ;
875832
876- this . emit ( 'pause' ) ;
833+ this . emit ( Events . PAUSE ) ;
877834
878835 return this ;
879836 } ,
@@ -882,7 +839,7 @@ var World = new Class({
882839 * Resumes the simulation, if paused.
883840 *
884841 * @method Phaser.Physics.Arcade.World#resume
885- * @fires Phaser.Physics.Arcade.World#resumeEvent
842+ * @fires Phaser.Physics.Arcade.Events#RESUME
886843 * @since 3.0.0
887844 *
888845 * @return {Phaser.Physics.Arcade.World } This World object.
@@ -891,7 +848,7 @@ var World = new Class({
891848 {
892849 this . isPaused = false ;
893850
894- this . emit ( 'resume' ) ;
851+ this . emit ( Events . RESUME ) ;
895852
896853 return this ;
897854 } ,
@@ -1372,8 +1329,8 @@ var World = new Class({
13721329 * Separates two Bodies.
13731330 *
13741331 * @method Phaser.Physics.Arcade.World#separate
1375- * @fires Phaser.Physics.Arcade.World#collideEvent
1376- * @fires Phaser.Physics.Arcade.World#overlapEvent
1332+ * @fires Phaser.Physics.Arcade.Events#COLLIDE
1333+ * @fires Phaser.Physics.Arcade.Events#OVERLAP
13771334 * @since 3.0.0
13781335 *
13791336 * @param {Phaser.Physics.Arcade.Body } body1 - The first Body to be separated.
@@ -1466,7 +1423,7 @@ var World = new Class({
14661423 {
14671424 if ( overlapOnly && ( body1 . onOverlap || body2 . onOverlap ) )
14681425 {
1469- this . emit ( 'overlap' , body1 . gameObject , body2 . gameObject , body1 , body2 ) ;
1426+ this . emit ( Events . OVERLAP , body1 . gameObject , body2 . gameObject , body1 , body2 ) ;
14701427 }
14711428 else
14721429 {
@@ -1475,7 +1432,7 @@ var World = new Class({
14751432
14761433 if ( body1 . onCollide || body2 . onCollide )
14771434 {
1478- this . emit ( 'collide' , body1 . gameObject , body2 . gameObject , body1 , body2 ) ;
1435+ this . emit ( Events . COLLIDE , body1 . gameObject , body2 . gameObject , body1 , body2 ) ;
14791436 }
14801437 }
14811438 }
@@ -1487,8 +1444,8 @@ var World = new Class({
14871444 * Separates two Bodies, when both are circular.
14881445 *
14891446 * @method Phaser.Physics.Arcade.World#separateCircle
1490- * @fires Phaser.Physics.Arcade.World#collideEvent
1491- * @fires Phaser.Physics.Arcade.World#overlapEvent
1447+ * @fires Phaser.Physics.Arcade.Events#COLLIDE
1448+ * @fires Phaser.Physics.Arcade.Events#OVERLAP
14921449 * @since 3.0.0
14931450 *
14941451 * @param {Phaser.Physics.Arcade.Body } body1 - The first Body to be separated.
@@ -1561,7 +1518,7 @@ var World = new Class({
15611518 {
15621519 if ( overlap !== 0 && ( body1 . onOverlap || body2 . onOverlap ) )
15631520 {
1564- this . emit ( 'overlap' , body1 . gameObject , body2 . gameObject , body1 , body2 ) ;
1521+ this . emit ( Events . OVERLAP , body1 . gameObject , body2 . gameObject , body1 , body2 ) ;
15651522 }
15661523
15671524 // return true if there was some overlap, otherwise false
@@ -1673,7 +1630,7 @@ var World = new Class({
16731630
16741631 if ( body1 . onCollide || body2 . onCollide )
16751632 {
1676- this . emit ( 'collide' , body1 . gameObject , body2 . gameObject , body1 , body2 ) ;
1633+ this . emit ( Events . COLLIDE , body1 . gameObject , body2 . gameObject , body1 , body2 ) ;
16771634 }
16781635
16791636 // sync changes back to the bodies
@@ -2143,10 +2100,8 @@ var World = new Class({
21432100 * Please use Phaser.Physics.Arcade.World#collide instead.
21442101 *
21452102 * @method Phaser.Physics.Arcade.World#collideSpriteVsTilemapLayer
2146- * @fires Phaser.GameObjects.GameObject#collideEvent
2147- * @fires Phaser.GameObjects.GameObject#overlapEvent
2148- * @fires Phaser.Physics.Arcade.World#collideEvent
2149- * @fires Phaser.Physics.Arcade.World#overlapEvent
2103+ * @fires Phaser.Physics.Arcade.Events#TILE_COLLIDE
2104+ * @fires Phaser.Physics.Arcade.Events#TILE_OVERLAP
21502105 * @since 3.0.0
21512106 *
21522107 * @param {Phaser.GameObjects.GameObject } sprite - The first object to check for collision.
@@ -2232,11 +2187,11 @@ var World = new Class({
22322187
22332188 if ( overlapOnly && body . onOverlap )
22342189 {
2235- sprite . emit ( 'overlap' , body . gameObject , tile , body , null ) ;
2190+ this . emit ( Events . TILE_OVERLAP , body . gameObject , tile , body ) ;
22362191 }
22372192 else if ( body . onCollide )
22382193 {
2239- sprite . emit ( 'collide' , body . gameObject , tile , body , null ) ;
2194+ this . emit ( Events . TILE_COLLIDE , body . gameObject , tile , body ) ;
22402195 }
22412196
22422197 // sync changes back to the body
@@ -2376,23 +2331,3 @@ var World = new Class({
23762331} ) ;
23772332
23782333module . exports = World ;
2379-
2380- /**
2381- * A physics-enabled Game Object collided with a Tile.
2382- * This event is emitted only if the Game Object's body has `onCollide` enabled.
2383- * @event Phaser.GameObjects.GameObject#collideEvent
2384- * @param {Phaser.GameObjects.GameObject } gameObject
2385- * @param {Phaser.Tilemaps.Tile } tile
2386- * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody } body
2387- * @see Phaser.Physics.Arcade.Body#onCollide
2388- */
2389-
2390- /**
2391- * A physics-enabled Game Object overlapped with a Tile.
2392- * This event is emitted only if the Game Object's body has `onOverlap` enabled.
2393- * @event Phaser.GameObjects.GameObject#overlapEvent
2394- * @param {Phaser.GameObjects.GameObject } gameObject
2395- * @param {Phaser.Tilemaps.Tile } tile
2396- * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody } body
2397- * @see Phaser.Physics.Arcade.Body#onOverlap
2398- */
0 commit comments