Commit graph

626 commits

Author SHA1 Message Date
Richard Davey
108b6bd2a3 Events call the world directly, avoids an unnecessary function jump. 2018-01-17 15:28:53 +00:00
Richard Davey
f41d016c9f Moved Matter over to use the plugin system. 2018-01-17 15:22:16 +00:00
Richard Davey
b17744df61 Merge branch 'master' of https://github.com/photonstorm/phaser 2018-01-17 03:42:03 +00:00
Richard Davey
ddba95873d Moved Arcade and Impact Physics over to the new plugin system 2018-01-17 03:41:58 +00:00
Michael Hadley
814e5af815 Remove recalculation of tile bounds from arcade physics 2018-01-16 19:03:13 -06:00
Richard Davey
ca7550aa6f Moved plugins 2018-01-16 18:38:29 +00:00
Michael Hadley
bf413ea604 Implemented tile & layer callbacks in arcade physics 2018-01-12 15:00:37 -06:00
Michael Hadley
ef58640026 Arcade: tilemap collisions/overlaps now emit appropriate events 2018-01-12 14:23:36 -06:00
Michael Hadley
8f0b428209 Bug fix in events: overlap used where collide should be 2018-01-12 14:20:48 -06:00
Richard Davey
f00f467eec Matter now using new EventEmitter. 2018-01-12 18:59:11 +00:00
Richard Davey
f9a1e27334 Removed un-used event files and references. 2018-01-12 17:20:16 +00:00
Richard Davey
c625b8735b Updated to using Event Emitter for all key managers and game objects. Events are now dispatched directly using arguments instead of Event objects, all managers updated to emit directly. 2018-01-12 17:09:21 +00:00
Michael Hadley
15825eacb3 Add note about circle bodies not currently being supported in Arcade tile intersection 2018-01-12 10:53:36 -06:00
Michael Hadley
bab399a02e Made CollideHandler consistent by returning value from logic branches
Each branch should return true/false based on whether a collision happened
2018-01-11 14:13:42 -06:00
Michael Hadley
00cebf8eae CollideGroupVsTilemapLayer implementation 2018-01-11 14:03:34 -06:00
Michael Hadley
5241798ab3 Pass TILE_BIAS from arcade world into tile colliding functions 2018-01-11 08:32:07 -06:00
Michael Hadley
98ae8009e0 Arcade rect vs tilemap layer collision handling 2018-01-10 20:47:25 -06:00
Michael Hadley
32788d6eb6 Stub arcade collide vs tilemap methods 2018-01-10 20:43:11 -06:00
Michael Hadley
e3699aaea0 Remove unnecessary Arcade Body#tilePadding 2018-01-10 19:34:22 -06:00
Richard Davey
d8f1ba03e9 Moved repository location 2018-01-09 21:43:56 +00:00
Richard Davey
0d90f75b5f Splitting the dev branch up into versions. 2016-11-22 01:36:56 +00:00
Richard Davey
4d4344bf03 Arcade Physics updated to use new Transform system. 2016-11-11 02:20:31 +00:00
photonstorm
26711241ac Disabled access to World and Camera for now. 2016-10-14 02:20:35 +01:00
Richard Davey
380e717e52 Finished off missing factories. Moved over the docs. Changed rogue @returns to @return everywhere. 2016-10-08 16:17:46 +01:00
Richard Davey
31592b98f1 The P2 Physics library has been updated to 0.7.1. This is still quite out of date, but as soon as they release their latest build (hopefully soon) we'll update to that. 2016-09-21 23:16:14 +01:00
Richard Davey
8a78029e2b Merge pull request #2728 from samme/issue-2720
Add a hint for resizing Body of scaled Sprites
2016-09-07 23:27:34 +01:00
James
42ca43d98c updated docs on Arcade body's setSize 2016-08-30 17:08:25 -05:00
samme
792ae127bf Add a hint for resizing Body of scaled Sprites 2016-08-29 12:50:05 -07:00
photonstorm
ad0e4aca2e Large batch of jshint fixes. 2016-08-25 13:03:41 +01:00
samme
b05becf962 Correct docs:
* `angularAcceleration`, `angularDrag`, and `angularVelocity` are measured in degrees.
* `angle` describes `velocity` and is unrelated to angular motion
2016-08-22 12:05:12 -07:00
photonstorm
11b0436a26 Fixed Arcade Physics Circle body collision, after the #2654 change broke it unintentionally. 2016-08-22 16:23:22 +01:00
photonstorm
7b9c4114b2 Preparing for 2.6.2 release. 2016-08-22 12:31:02 +01:00
Richard Davey
19342fa3af ArcadePhysics Body.rotation now reads its initial value from sprite.angle instead of sprite.rotation. The property was immediately replaced with the correct value in Body.preUpdate regardless, but it keeps it consistent (thanks @samme #2708) 2016-08-21 10:27:58 +01:00
Richard Davey
9654a4b3c5 Consolidating Layers into View class. 2016-07-25 01:39:46 +01:00
Richard Davey
6947057427 The property checkCollision.none in the ArcadePhysics.Body class was available, but never used internally. It is now used and checked by the separate method. By setting checkCollision.none = true you can disable all collision and overlap checks on a Body, but still retain its motion updates (thanks @samme #2661) 2016-07-23 10:01:38 +01:00
Richard Davey
46c20ab00a The property checkCollision.none has been removed from the ArcadePhysics.Body class. It was never used internally, so lead to confusion about its use. To disable a body, use body.enable = false (thanks @samme #2661) 2016-07-23 09:43:01 +01:00
photonstorm
3ba00bbf2d Loads of work on tilemap collision, and offset support. You can now collide with a tilemap no matter where it is on the screen, or which layer it's from. 2016-07-22 17:02:10 +01:00
photonstorm
0e25c5acac Revert getTiles call. 2016-07-22 14:08:54 +01:00
Richard Davey
d8560eb3bc Fixed Tilemap collision. 2016-07-22 04:32:56 +01:00
Leopoldo Brines
18472f5998 Fix 'TypeError: target.center is undefined' 2016-07-20 18:34:02 -04:00
Boniatillo.com
3d1b10c310 jsdoc fix: replace #onTop for #onCeiling
Modified the jsdoc of Phaser.Arcade.Body.onCeiling, by replacing the #onTop reference for #onCeiling.
2016-07-19 08:32:34 -04:00
photonstorm
ac2516f5aa 2.6.1 Release. 2016-07-11 10:07:56 +01:00
Richard Davey
cfb2b813ef Fixed Uncaught TypeError: Cannot set property 'x' of undefined in Body.js (thanks @ErwanErwan #2607) 2016-07-08 18:54:00 +01:00
photonstorm
61ce14f332 P2.World.clear will now clear out the World.walls property, resetting all of the wall bounds to null. This allows the walls to be re-created accurately when the P2 World is reset, which happens on a State change or restart (thanks @ewpolly1 @codermua #2574) 2016-07-08 13:02:58 +01:00
photonstorm
dfd9203e0a onWorldBounds now sends the bounds it collided with. 2016-07-08 11:28:45 +01:00
Richard Davey
c0ba439e82 ArcadePhysics.Body.onCollide is a new Signal that is dispatched whenever the Body collides with another Body. Due to the potentially high volume of signals this could create it is disabled by default. To use this feature set this property to a Phaser.Signal: sprite.body.onCollide = new Phaser.Signal() and it will be called when a collision happens, passing two arguments: the sprites which collided.
ArcadePhysics.Body.onOverlap is a new Signal that is dispatched whenever the Body overlaps with another Body. Due to the potentially high volume of signals this could create it is disabled by default. To use this feature set this property to a Phaser.Signal: `sprite.body.onOverlap = new Phaser.Signal()` and it will be called when an overlap happens, passing two arguments: the sprites which collided.
2016-07-07 23:16:18 +01:00
Richard Davey
6ba3c9401f ArcadePhysics.Body.setCircle is a new method that allows you to define an Arcade Physics Body as being a circle instead of a rectangle. You can control the radius of the body and the offset from the parent sprite.
ArcadePhysics.World.separateCircle is a new method that handles all circular body collisions internally within Arcade Physics (thanks @VitaZheltyakov)

All of the Arcade Physics internal methods, such as `collideGroupVsSelf`, `collideSpriteVsSprite` and so on, have been updated to work with circular body shapes (thanks @VitaZheltyakov)

ArcadePhysics.Body.onWorldBounds is a new Signal that is dispatched whenever the Body collides with the world bounds, something that was previously difficult to detect. Due to the potentially high volume of signals this could create it is disabled by default. To use this feature set this property to a Phaser.Signal: `sprite.body.onWorldBounds = new Phaser.Signal()` and it will be called when a collision happens, passing one argument: the sprite on which it occurred.
2016-07-07 21:58:39 +01:00
photonstorm
261155a683 Merged the arcade-circles branch back into 2.6 and tidied up lots of the source code. Needs checking as not working properly with rect vs. circle, but fine with circle vs. circle. 2016-07-07 16:45:10 +01:00
photonstorm
4da3b15ae2 Renamed alignTo to alignIn, and added the new method alignTo, to allow for Sprite to Sprite alignment. Updated all of the Bounds and TS defs. 2016-06-16 17:01:51 +01:00
Richard Davey
70be74cb36 Lots of work on Body.moveTo and Body.moveFrom. Now working nicely. 2016-06-15 04:12:47 +01:00
Richard Davey
b5cc01132c Body.move tests. 2016-06-14 23:45:00 +01:00
Richard Davey
1daf897b23 Small styling fixes. 2016-06-09 23:27:19 +01:00
Upperfoot
bab2fac729 Resolved issue with tilemapLayer collision. 2016-06-08 23:52:56 +01:00
Craig Whiteside
212a07b9ac Fixed problem with missing parameter in tileCheckX and tileCheckY. 2016-06-07 14:00:34 +01:00
Craig Whiteside
7a1667fa7e Fixed typo on collision for TileMapLayers (lesson to triple check your code...) 2016-06-06 15:43:51 +01:00
Richard Davey
05ca827c2b Merge pull request #2522 from Upperfoot/master
Fixing tileMap collision when tileMapLayer is set to a position other than 0,0
2016-06-03 12:45:37 +01:00
photonstorm
a81fe3cf02 jshint fixes. 2016-06-02 15:38:05 +01:00
Vitaliy
cd3742f9f2 Corrected intersects fuction
Added protection against incorrect handling collisions. Clashes with the body itself will not be processed.
2016-05-31 01:18:17 +03:00
photonstorm
c1c2e6bc9d Removed left-over Body.isCircle checks. 2016-05-23 23:02:04 +01:00
photonstorm
e974ff4ee9 Removed Circle functions and updated setSize docs. 2016-05-23 13:16:21 +01:00
photonstorm
16e9acac84 Updated Body.reset call. 2016-05-23 12:54:41 +01:00
photonstorm
09dd84565e Arcade Physics Body incorrectly positioned if the Sprite had a negative scale (see http://www.html5gamedevs.com/topic/22695-247-248-body-anchoring-any-migration-tips/) (thanks @SBCGames @icameron @Nuuf @EvolViper #2488 #2490) 2016-05-23 12:46:01 +01:00
Upperfoot
4a3e8f2b4a Take into consideration Tilemap position into collision 2016-05-19 11:06:49 +01:00
photonstorm
7018ca2132 Position in Body.reset #2470 2016-05-16 15:20:44 +01:00
photonstorm
ac89d1aec7 Arcade Physics Body has a new property worldBounce. This controls the elasticity of the Body specifically when colliding with the World bounds. By default this property is null, in which case Body.bounce is used instead. Set this property to a Phaser.Point object in order to enable a World bounds specific bounce value (thanks @VitaZheltyakov #2465) 2016-05-16 13:53:12 +01:00
photonstorm
f9994fac75 Fixed a bug in Arcade Physics Body.preUpdate which would incorrectly apply the position of an offset Body (one which has had Body.setSize used on it) when combined with a Sprite with a non-zero anchor (thanks @SBCGames #2470) 2016-05-16 13:39:46 +01:00
photonstorm
19dce62734 Arcade Physics has had a new world argument added to the following functions: distanceBetween, distanceToXY, distanceToPointer, angleBetween, angleToXY and angleToPointer. The argument (which is false by default), when enabled will calculate the angles or distances based on the Game Objects world property, instead of its x and y properties. This allows it to work for objects that are placed in offset Groups, or are children of other display objects (thanks @Skeptron for the thread #2463) 2016-05-16 13:31:57 +01:00
photonstorm
f494c867c7 Fixed an issue in the Arcade Physics overlap method where it would only detect overlaps up to the max bias threshold and no further (thanks @rgk #2441)
The Arcade Physics overlap method would return false if two bodies were overlapping but neither had any velocity (i.e. they were embedded into each other)
2016-04-25 11:38:51 +01:00
photonstorm
628dd1c420 P2.Body.offset is now used and applied to the Sprite position during rendering. The values given are normal pixel values, and offset the P2 Body from the center of the Sprite (thanks @Mourtz #2430) 2016-04-18 20:57:41 +01:00
photonstorm
41f81d39b7 jsdocs update (and removed isCircle switch) 2016-04-18 16:17:47 +01:00
photonstorm
ac4acfb912 Removed Arcade Physics Circle support (now in its own branch) ready for 2.4.7 release. 2016-04-14 13:23:28 +01:00
photonstorm
4d8753e9ce Tidying up for 2.4.7. 2016-04-14 12:57:05 +01:00
photonstorm
aad499b025 Tidying up the code base for 2.4.7. 2016-04-14 12:43:10 +01:00
photonstorm
f4277efc20 Alternative snooker-ball like collision test. 2016-04-11 16:43:17 +01:00
photonstorm
3c4e63fda5 World.separateCircle is working with circle vs. circle bodies. 2016-04-08 03:37:49 +01:00
photonstorm
d009b8d769 Circle vs. Circle rebound code started. 2016-04-07 19:32:27 +01:00
photonstorm
cc5361dd6d World.separate has been optimized to cut down on the number of calls to intersect from 3 calls per Game Object collision check, to 2. So if you were colliding 50 sprites it will reduce the call count from 150 to 100 per frame. It also reduces the calls made to seperateX and seperateY by the same factor.
Two immovable bodies would never set their overlap data, even if an overlap only check was being made. As this is useful data to have this has been changed. Two immovable bodies will still never separate from each other, but they _will_ have their `overlapX` and `overlapY` properties calculated now.
2016-04-07 18:04:45 +01:00
photonstorm
50e126f59e * Body has two new properties: left and top. These are the same as Body.x and Body.y but allow you to pass the Body to geometry level functions such as Circle.contains.
* Body.setCircle allows you to define a Body as using a circle to collide with instead of a rectangle. You can set the radius of the collision circle and an offset.
* Body.render now renders both circle and rectangle body shapes to the Debug canvas.
* World.intersects has been updated to support both circle and rectangle body shapes, and supports quick-paths for circle vs. circle and rect vs. rect checks.
* World.circleBodyIntersects is a new method that checks for intersection between a Body that has been defined as a circle, and a normal rectangle based Body. This is used internally by World.intersects, but exposed for direct calls as well.
2016-04-07 17:01:16 +01:00
photonstorm
952b5c04ea The start of Arcade Physics circle bodies. 2016-04-07 14:32:53 +01:00
photonstorm
e5ceb7e9bc P2.World.setBounds has been re-written completely. If the World is resized it no longer removes the P2 body instances and re-creates them. Instead it checks to see which walls are required and then just moves the position of the shapes instead, or updates them, or creates or destroys them as required. This is far more efficnent, especially in a game which see's a lot of world bounds changes (i.e. resizes responsively in browser) 2016-04-07 01:56:42 +01:00
photonstorm
5c261821fe P2.World.updateBoundsCollisionGroup didn't set the _boundsOwnGroup private var, meaning the World.setBounds method wasn't able to restore previously set collision masks automatically (thanks @jmp909 #2183) 2016-04-07 01:25:52 +01:00
photonstorm
4d5a037ae5 P2.World.updateBoundsCollisionGroup wouldn't use the boundsCollisionGroup mask if you passed true as the argument, only if it was left undefined. 2016-04-07 01:18:19 +01:00
Richard Davey
2f0231b3cd Merge pull request #2415 from jakewilson/dev
Fixed and added warnings.
2016-04-06 01:21:09 +01:00
photonstorm
6933b41e6f Arcade.Body's speed property was only set when the body moved, it now updates regardless (thanks @mark-henry #2417) 2016-04-05 23:06:57 +01:00
Jake Wilson
96a79cd91a Added warning if physics body is enabled on unknown physics system. 2016-04-05 11:23:17 -04:00
photonstorm
f40cfbe2ae 2015 - 2016. 2016-04-04 22:16:16 +01:00
Chad Engler
a510761bf1 fix typo in componentToHex 2016-03-09 15:54:40 -08:00
Richard Davey
0c48c2d6a8 * Added P2.Body.thrustLeft which will move the Body to the left by the speed given (thanks James Pryor)
* Added P2.Body.thrustRight which will move the Body to the right by the speed given (thanks James Pryor)
2016-03-01 22:31:58 +00:00
Richard Davey
5801f1aa15 jshint fixes. 2016-02-04 23:39:58 +00:00
photonstorm
a7c360425f Tidying up code and docs. 2016-02-04 16:23:40 +00:00
Richard Davey
a8b04c4bf1 Merge pull request #2171 from mattrick16/dev
Add method to angle Display Objects relative to world
2016-02-04 18:21:14 +02:00
photonstorm
af4c938299 Docs update (#1967) 2016-02-04 16:05:45 +00:00
Richard Davey
8e6b88cda8 Merge pull request #2172 from jonjanisch/dev
Inconsistency in arcade.collide processCallback param order #667
2016-02-02 17:39:46 +02:00
Richard Davey
6a50e18bf0 Merge pull request #1610 from yigitozdemir/dev
On Ceiling Method Addition
2016-02-01 21:14:12 +02:00
Jonathan Janisch
24c85dbb35 Inconsistency in arcade.collide processCallback param order #667 2015-10-27 23:48:14 -04:00
mattrick
8843a4ad09 Add worldAngleToPointer 2015-10-27 16:55:23 -07:00
photonstorm
b91de47d8d Readme and JSDocs updates. 2015-10-13 12:01:08 +01:00
Christoph Dörfel
a8c4930d42 Add JsDoc comment for Body#addPhaserPolygon return value 2015-09-17 12:11:49 +02:00
Christoph Dörfel
4c9412088c Add option to prefix shape name and optimize JSON output 2015-09-16 14:00:24 +02:00
photonstorm
7487c15f0e Doc updates. 2015-09-08 15:56:28 +01:00