Skip to content

Commit 2a51d6b

Browse files
committed
Arcade Physics docs revisions
1 parent f869794 commit 2a51d6b

8 files changed

Lines changed: 216 additions & 143 deletions

File tree

src/physics/arcade/ArcadePhysics.js

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,19 @@ var PluginCache = require('../../plugins/PluginCache');
1515
var Vector2 = require('../../math/Vector2');
1616
var World = require('./World');
1717

18-
// All methods in this class are available under `this.physics` in a Scene.
19-
2018
/**
2119
* @classdesc
22-
* [description]
20+
* The Arcade Physics Plugin belongs to a Scene and sets up and manages the Scene's physics simulation.
21+
* It also holds some useful methods for moving and rotating Arcade Physics Bodies.
22+
*
23+
* You can access it from within a Scene using `this.physics`.
2324
*
2425
* @class ArcadePhysics
2526
* @memberOf Phaser.Physics.Arcade
2627
* @constructor
2728
* @since 3.0.0
2829
*
29-
* @param {Phaser.Scene} scene - [description]
30+
* @param {Phaser.Scene} scene - The Scene that this Plugin belongs to.
3031
*/
3132
var ArcadePhysics = new Class({
3233

@@ -35,7 +36,7 @@ var ArcadePhysics = new Class({
3536
function ArcadePhysics (scene)
3637
{
3738
/**
38-
* [description]
39+
* The Scene that this Plugin belongs to.
3940
*
4041
* @name Phaser.Physics.Arcade.ArcadePhysics#scene
4142
* @type {Phaser.Scene}
@@ -44,7 +45,7 @@ var ArcadePhysics = new Class({
4445
this.scene = scene;
4546

4647
/**
47-
* [description]
48+
* The Scene's Systems.
4849
*
4950
* @name Phaser.Physics.Arcade.ArcadePhysics#systems
5051
* @type {Phaser.Scenes.Systems}
@@ -53,7 +54,7 @@ var ArcadePhysics = new Class({
5354
this.systems = scene.sys;
5455

5556
/**
56-
* [description]
57+
* A configuration object. Union of the `physics.arcade.*` properties of the GameConfig and SceneConfig objects.
5758
*
5859
* @name Phaser.Physics.Arcade.ArcadePhysics#config
5960
* @type {object}
@@ -62,7 +63,7 @@ var ArcadePhysics = new Class({
6263
this.config = this.getConfig();
6364

6465
/**
65-
* [description]
66+
* The physics simulation.
6667
*
6768
* @name Phaser.Physics.Arcade.ArcadePhysics#world
6869
* @type {Phaser.Physics.Arcade.World}
@@ -71,7 +72,7 @@ var ArcadePhysics = new Class({
7172
this.world;
7273

7374
/**
74-
* [description]
75+
* An object holding the Arcade Physics factory methods.
7576
*
7677
* @name Phaser.Physics.Arcade.ArcadePhysics#add
7778
* @type {Phaser.Physics.Arcade.Factory}
@@ -124,12 +125,12 @@ var ArcadePhysics = new Class({
124125
},
125126

126127
/**
127-
* [description]
128+
* Creates the physics configuration for the current Scene.
128129
*
129130
* @method Phaser.Physics.Arcade.ArcadePhysics#getConfig
130131
* @since 3.0.0
131132
*
132-
* @return {object} [description]
133+
* @return {object} The physics configuration.
133134
*/
134135
getConfig: function ()
135136
{
@@ -145,31 +146,20 @@ var ArcadePhysics = new Class({
145146
},
146147

147148
/**
148-
* Checks for overlaps between two Game Objects. The objects can be any Game Object that have an Arcade Physics Body.
149-
*
150-
* Unlike {@link #collide} the objects are NOT automatically separated or have any physics applied, they merely test for overlap results.
151-
*
152-
* Both the first and second parameter can be arrays of objects, of differing types.
153-
* If two arrays are passed, the contents of the first parameter will be tested against all contents of the 2nd parameter.
154-
*
155-
* ##### Tilemaps
156-
*
157-
* Any overlapping tiles, including blank/null tiles, will give a positive result. Tiles marked via {@link Phaser.Tilemap#setCollision} (and similar methods) have no special status, and callbacks added via {@link Phaser.Tilemap#setTileIndexCallback} or {@link Phaser.Tilemap#setTileLocationCallback} are not invoked. So calling this method without any callbacks isn't very useful.
158-
*
159-
* If you're interested only in whether an object overlaps a certain tile or class of tiles, filter the tiles with `processCallback` and then use the result returned by this method. Blank/null tiles can be excluded by their {@link Phaser.Tile#index index} (-1).
160-
*
161-
* If you want to take action on certain overlaps, examine the tiles in `collideCallback` and then handle as you like.
149+
* Tests if Game Objects overlap. See {@link Phaser.Physics.Arcade.World#overlap}
162150
*
163151
* @method Phaser.Physics.Arcade.ArcadePhysics#overlap
164152
* @since 3.0.0
165153
*
166-
* @param {(Phaser.GameObjects.GameObject|array)} object1 - The first object or array of objects to check. Can be any Game Object that has an Arcade Physics Body.
167-
* @param {(Phaser.GameObjects.GameObject|array)} object2 - The second object or array of objects to check. Can be any Game Object that has an Arcade Physics Body.
168-
* @param {ArcadePhysicsCallback} [overlapCallback=null] - An optional callback function that is called if the objects overlap. The two objects will be passed to this function in the same order in which you specified them, unless you are checking Group vs. Sprite, in which case Sprite will always be the first parameter.
169-
* @param {ArcadePhysicsCallback} [processCallback=null] - A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `overlapCallback` will only be called if this callback returns `true`.
154+
* @param {ArcadeColliderType} object1 - The first object or array of objects to check.
155+
* @param {ArcadeColliderType} [object2] - The second object or array of objects to check, or `undefined`.
156+
* @param {ArcadePhysicsCallback} [collideCallback] - An optional callback function that is called if the objects collide.
157+
* @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `collideCallback` will only be called if this callback returns `true`.
170158
* @param {*} [callbackContext] - The context in which to run the callbacks.
171159
*
172-
* @return {boolean} True if an overlap occurred otherwise false.
160+
* @return {boolean} True if at least one Game Object overlaps another.
161+
*
162+
* @see Phaser.Physics.Arcade.World#overlap
173163
*/
174164
overlap: function (object1, object2, overlapCallback, processCallback, callbackContext)
175165
{
@@ -181,18 +171,20 @@ var ArcadePhysics = new Class({
181171
},
182172

183173
/**
184-
* [description]
174+
* Tests if Game Objects overlap and separates them (if possible). See {@link Phaser.Physics.Arcade.World#collide}.
185175
*
186176
* @method Phaser.Physics.Arcade.ArcadePhysics#collide
187177
* @since 3.0.0
188178
*
189-
* @param {(Phaser.GameObjects.GameObject|array)} object1 - The first object or array of objects to check. Can be any Game Object that has an Arcade Physics Body.
190-
* @param {(Phaser.GameObjects.GameObject|array)} object2 - The second object or array of objects to check. Can be any Game Object that has an Arcade Physics Body.
191-
* @param {ArcadePhysicsCallback} [collideCallback=null] - An optional callback function that is called if the objects collide. The two objects will be passed to this function in the same order in which you specified them, unless you are checking Group vs. Sprite, in which case Sprite will always be the first parameter.
192-
* @param {ArcadePhysicsCallback} [processCallback=null] - A callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`.
179+
* @param {ArcadeColliderType} object1 - The first object or array of objects to check.
180+
* @param {ArcadeColliderType} [object2] - The second object or array of objects to check, or `undefined`.
181+
* @param {ArcadePhysicsCallback} [collideCallback] - An optional callback function that is called if the objects collide.
182+
* @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`.
193183
* @param {*} [callbackContext] - The context in which to run the callbacks.
194184
*
195-
* @return {boolean} True if a collision occurred otherwise false.
185+
* @return {boolean} True if any overlapping Game Objects were separated, otherwise false.
186+
*
187+
* @see Phaser.Physics.Arcade.World#collide
196188
*/
197189
collide: function (object1, object2, collideCallback, processCallback, callbackContext)
198190
{
@@ -204,25 +196,25 @@ var ArcadePhysics = new Class({
204196
},
205197

206198
/**
207-
* [description]
199+
* Pauses the simulation.
208200
*
209201
* @method Phaser.Physics.Arcade.ArcadePhysics#pause
210202
* @since 3.0.0
211203
*
212-
* @return {Phaser.Physics.Arcade.World} [description]
204+
* @return {Phaser.Physics.Arcade.World} The simulation.
213205
*/
214206
pause: function ()
215207
{
216208
return this.world.pause();
217209
},
218210

219211
/**
220-
* [description]
212+
* Resumes the simulation (if paused).
221213
*
222214
* @method Phaser.Physics.Arcade.ArcadePhysics#resume
223215
* @since 3.0.0
224216
*
225-
* @return {Phaser.Physics.Arcade.World} [description]
217+
* @return {Phaser.Physics.Arcade.World} The simulation.
226218
*/
227219
resume: function ()
228220
{

0 commit comments

Comments
 (0)