Skip to content

Commit c46ab84

Browse files
committed
Use body center in closest, furthest
1 parent c25331c commit c46ab84

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

src/physics/arcade/ArcadePhysics.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var World = require('./World');
2323
* It also holds some useful methods for moving and rotating Arcade Physics Bodies.
2424
*
2525
* You can access it from within a Scene using `this.physics`.
26-
*
26+
*
2727
* Arcade Physics uses the Projection Method of collision resolution and separation. While it's fast and suitable
2828
* for 'arcade' style games it lacks stability when multiple objects are in close proximity or resting upon each other.
2929
* The separation that stops two objects penetrating may create a new penetration against a different object. If you
@@ -186,7 +186,7 @@ var ArcadePhysics = new Class({
186186
* If two Groups or arrays are passed, each member of one will be tested against each member of the other.
187187
*
188188
* If **only** one Group is passed (as `object1`), each member of the Group will be collided against the other members.
189-
*
189+
*
190190
* If **only** one Array is passed, the array is iterated and every element in it is tested against the others.
191191
*
192192
* Two callbacks can be provided. The `collideCallback` is invoked if a collision occurs and the two colliding
@@ -221,15 +221,15 @@ var ArcadePhysics = new Class({
221221

222222
/**
223223
* This advanced method is specifically for testing for collision between a single Sprite and an array of Tile objects.
224-
*
224+
*
225225
* You should generally use the `collide` method instead, with a Sprite vs. a Tilemap Layer, as that will perform
226226
* tile filtering and culling for you, as well as handle the interesting face collision automatically.
227-
*
227+
*
228228
* This method is offered for those who would like to check for collision with specific Tiles in a layer, without
229229
* having to set any collision attributes on the tiles in question. This allows you to perform quick dynamic collisions
230230
* on small sets of Tiles. As such, no culling or checks are made to the array of Tiles given to this method,
231231
* you should filter them before passing them to this method.
232-
*
232+
*
233233
* Important: Use of this method skips the `interesting faces` system that Tilemap Layers use. This means if you have
234234
* say a row or column of tiles, and you jump into, or walk over them, it's possible to get stuck on the edges of the
235235
* tiles as the interesting face calculations are skipped. However, for quick-fire small collision set tests on
@@ -254,10 +254,10 @@ var ArcadePhysics = new Class({
254254

255255
/**
256256
* This advanced method is specifically for testing for overlaps between a single Sprite and an array of Tile objects.
257-
*
257+
*
258258
* You should generally use the `overlap` method instead, with a Sprite vs. a Tilemap Layer, as that will perform
259259
* tile filtering and culling for you, as well as handle the interesting face collision automatically.
260-
*
260+
*
261261
* This method is offered for those who would like to check for overlaps with specific Tiles in a layer, without
262262
* having to set any collision attributes on the tiles in question. This allows you to perform quick dynamic overlap
263263
* tests on small sets of Tiles. As such, no culling or checks are made to the array of Tiles given to this method,
@@ -368,7 +368,7 @@ var ArcadePhysics = new Class({
368368

369369
/**
370370
* Finds the Dynamic Body closest to a source point or object.
371-
*
371+
*
372372
* If two or more bodies are the exact same distance from the source point, only the first body
373373
* is returned.
374374
*
@@ -390,7 +390,7 @@ var ArcadePhysics = new Class({
390390

391391
bodies.iterate(function (target)
392392
{
393-
var distance = DistanceSquared(x, y, target.x, target.y);
393+
var distance = DistanceSquared(x, y, target.center.x, target.center.y);
394394

395395
if (distance < min)
396396
{
@@ -405,7 +405,7 @@ var ArcadePhysics = new Class({
405405

406406
/**
407407
* Finds the Dynamic Body farthest from a source point or object.
408-
*
408+
*
409409
* If two or more bodies are the exact same distance from the source point, only the first body
410410
* is returned.
411411
*
@@ -427,7 +427,7 @@ var ArcadePhysics = new Class({
427427

428428
bodies.iterate(function (target)
429429
{
430-
var distance = DistanceSquared(x, y, target.x, target.y);
430+
var distance = DistanceSquared(x, y, target.center.x, target.center.y);
431431

432432
if (distance > max)
433433
{
@@ -545,10 +545,10 @@ var ArcadePhysics = new Class({
545545
/**
546546
* This method will search the given rectangular area and return an array of all physics bodies that
547547
* overlap with it. It can return either Dynamic, Static bodies or a mixture of both.
548-
*
548+
*
549549
* A body only has to intersect with the search area to be considered, it doesn't have to be fully
550550
* contained within it.
551-
*
551+
*
552552
* If Arcade Physics is set to use the RTree (which it is by default) then the search for is extremely fast,
553553
* otherwise the search is O(N) for Dynamic Bodies.
554554
*
@@ -568,7 +568,7 @@ var ArcadePhysics = new Class({
568568
{
569569
return OverlapRect(this.world, x, y, width, height, includeDynamic, includeStatic);
570570
},
571-
571+
572572
/**
573573
* The Scene that owns this plugin is shutting down.
574574
* We need to kill and reset all internal properties as well as stop listening to Scene events.

0 commit comments

Comments
 (0)