Commit graph

87 commits

Author SHA1 Message Date
photonstorm
f40cfbe2ae 2015 - 2016. 2016-04-04 22:16:16 +01: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
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
Richard Davey
a56cd31638 jsdoc updates. 2015-07-31 18:39:37 +01:00
photonstorm
858ad51610 Phaser 2.4 release. 2015-07-22 15:31:30 +01:00
photonstorm
f15fe6706c All undefined argument checks were changed from if (typeof x === 'undefined') to if (x === undefined) removing the typeof check and saving some bytes across the codebase in the process. 2015-07-22 10:37:15 +01:00
Richard Davey
9e38bf974a World.stateChange is a new method that is called whenever the state changes or restarts. It resets the world x/y coordinates back to zero and then resets the Camera.
Sprites with Arcade Physics bodies that had `collideWorldBounds` enabled would be moved to the wrong position if you restarted a State (or swapped to a new State) that reset the world bounds (thanks @vulvulune #1775)
2015-07-22 01:24:26 +01:00
Casey Clyde
e935df328d Sprite vs Tilemap can now check for overlap, without trying to separate 2015-05-23 22:39:12 -07:00
photonstorm
432516fa0f Physics.Arcade.sort has a new property 'sortDirection'. If not specified it will use World.sortDirection. If the Group given as the first parameter has its physicsSortDirection property set that will override any other setting.
Physics.Arcade.sort now calls one of four functions: sortLeftRight, sortRightLeft, sortTopBottom and sortBottomTop. Each of which takes 2 Sprites as arguments.

Physics.Arcade.sort now doesn't bail out if the Group contains a mixture of physics and non-physics enabled objects, as the Group hash is now only ever populated with physics enabled objects. Also the sort comparison functions no longer return -1 if the bodies are invalid, but zero instead (#1721)
2015-04-13 16:29:34 +01:00
photonstorm
77eaa7e707 Optimised World.collideHandler and added SORT_NONE option. 2015-03-23 15:05:57 +00:00
photonstorm
f99f182a6f Arcade Physics is now using a spacial pre-sort for all Sprite vs. Group and Group vs. Group collisions. You can define the direction the sort will prioritise via the new sortDirection property. By default it is set to Phaser.Physics.Arcade.LEFT_RIGHT. For example if you are making a horizontally scrolling game, where the player starts on the left and moves to the right, then this sort order will allow the physics system to quickly eliminate any object to the right of the players bounds. This cuts down on the sheer volume of actual collision checks needing to be made. In a densely populated level it can improve fps rate dramatically.
There are 3 other directions available (`RIGHT_LEFT`, `TOP_BOTTOM` and `BOTTOM_TOP`) and which one you need will depend on your game type. If you were making a vertically scrolling shoot-em-up then you'd pick `BOTTOM_TOP` so it sorts all objects above and can bail out quickly.

More importantly you can switch the `sortDirection` at run-time with no loss of performance. Just make sure you do it *before* running any collision checks. So if you had a large 8-way scrolling world you could set the `sortDirection` to match the direction the player was moving in and adjust it in real-time, getting the benefits as you go. My thanks to Aaron Lahman for inspiring this update.
2015-02-26 21:24:07 +00:00
photonstorm
03a2db18cb Added extra protection in the case of mixed-type Groups.
Removed window vars and replaced with stats property.
Removed redundant if/else checks.
2015-02-25 06:06:40 +00:00
photonstorm
8aec760cd5 First pass at spacial sorting in World.collide. 2015-02-25 05:39:02 +00:00
photonstorm
a69e53f901 Copyright date change. 2015-02-25 03:36:23 +00:00
photonstorm
dee13d52d8 jshint fix. 2015-02-25 02:50:57 +00:00
photonstorm
c799dfe7da Fixed physics postUpdate issue causing particles and all kinds of things to go awry. 2015-02-25 02:18:05 +00:00
photonstorm
3d399f1b14 Removed the final few private vars from computeVelocity 2015-02-25 00:04:53 +00:00
photonstorm
42b316473d jsdoc fix. 2015-02-23 13:58:57 +00:00
photonstorm
eb732e1d90 Refactored ArcadePhysics.World to remove global property use and array length caches. 2015-02-19 04:59:55 +00:00
photonstorm
052b9a7e06 Separated the Tilemap specific code from World. 2015-02-17 15:49:53 +00:00
photonstorm
4bb1adcf36 Typo fix. 2015-02-17 06:00:18 +00:00
photonstorm
86f05160b7 Removed array length vars and added strict equalities. 2015-02-17 05:13:12 +00:00
photonstorm
18ff04810f ArcadePhysics.distanceToPointer now calculates the distance in world space values.
ArcadePhysics.moveToPointer no longer goes crazy if the maxTime parameter is given and the Sprite is positioned in a larger game world (thanks @AnderbergE #1472)
2015-02-10 22:16:35 +00:00
photonstorm
816a80f39a If Body.customSeparateX or customSeparateY is true then the Body will no longer be automatically separated from a **Tilemap** collision or exchange any velocity. The amount of pixels that the Body has intersected the tile is available in Body.overlapX and overlapY, so you can use these values to perform your own separation in your collision callback (#992) 2015-02-10 12:58:12 +00:00
Richard Davey
9efca46021 Merge pull request #1582 from micahjohnston/dev
Fix doc comment on Phaser.Physics.Arcade#getObjectsAtLocation.
2015-02-03 20:45:33 +00:00
zekoff
0ccd225e08 Allow max of 0 in computeVelocity
Previous method of setting default max did not allow falsey values.
2015-02-03 11:36:53 -06:00
Micah Johnston
34d443153f fix argument name in comment on Phaser.Physics.Arcade#getObjectsAtLocation. 2015-01-30 05:48:34 -07:00
Micah Johnston
401d2fe847 Fix doc comment on Phaser.Physics.Arcade#getObjectsAtLocation. 2015-01-29 18:13:03 -07:00
photonstorm
587c3e5f6a Arcade.Body.friction allows you to have more fine-grained control over the amount of velocity passed between bodies on collision. 2015-01-18 12:24:00 +00:00
photonstorm
0f42b530eb Physics.Arcade.isPaused allows you to toggle Arcade Physics processing on and off. If true the Body.preUpdate method will be skipped, halting all motion for all bodies. Note that other methods such as collide will still work, so be careful not to call them on paused bodies. 2015-01-10 00:30:02 +00:00
photonstorm
8cd98e2e36 jsdocs fixes. 2015-01-05 10:59:10 +00:00
Paul
dab8772de0 Documentation - consistency updates
- Updated `readOnly` doclet to `readonly`

- `array` refined to `type[]`, where such information was immediately
determinable.

- Updated {Any}/{*} to {any}; {...*} is standard exception

- Udated {Object} to {object}
2014-11-30 04:03:35 -08:00
Pete Baron
bc70ce74b5 Minor logic fix to nested loop counters. 2014-11-12 15:00:26 +13:00
Pete Baron
1c7059ea6c Merge remote-tracking branch 'phaser-github/dev' into dev
Conflicts:
	src/animation/FrameData.js
	src/core/Game.js
	src/particles/arcade/Emitter.js
	src/time/Time.js
	src/tween/Tween.js
2014-11-12 13:03:52 +13:00
Pete Baron
af09290cbf Add getObjectsAtLocation method in Arcade physics. 2014-11-12 11:24:38 +13:00
photonstorm
8bf93fb658 ArcadePhysics.skipQuadTree is now set to true by default. A QuadTree is a wonderful thing if the objects in your game are well spaced out. But in tightly packed games, especially those with tilemaps or single-screen games, they are a considerable performance drain and eat up CPU. We've taken the decision to disable the Arcade Physics QuadTree by default. It's all still in there and can be re-enabled via game.physics.arcade.skipQuadTree = false, but please only do so if you're sure your game benefits from this. 2014-11-11 01:05:58 +00:00
DanX
3a1ec3c5c1 Fix docs for collide and collideHandler 2014-09-26 22:37:11 -03:00
photonstorm
20551f9129 Lots of jsdocs fixes ready for the new doc generator. 2014-09-16 17:35:08 +01:00
Carlos Martinez
ec9a8b6903 Firxed for travis build. 2014-09-01 15:03:29 +01:00
Carlos Martinez
9843818f30 Merge branch 'dev' of https://github.com/photonstorm/phaser into dev 2014-09-01 14:19:50 +01:00
Carlos Martinez
0640cc0c03 Added support to pass 2 array in Arcade collide and overlap (response to an issue). 2014-09-01 14:01:36 +01:00
photonstorm
070e33f1e7 ArcadePhysics.overlap has been updated so that the Body.overlapX/Y properties are set to the amount the two bodies overlapped by. Previously they were zero and only populated during the separation phase, but now the data is available for just overlap checks as well. You can then use these values in your ovrelap callback as required - note that they are changed for every check, so a Sprite overlap tested against 10 other sprites will have the overlapX/Y values updated 10 times in a single collision pass, so you can only safely use the values in the callback (#641) 2014-09-01 03:54:55 +01:00
photonstorm
69b9e5eb7c Arcade.overlap and collide are now more consistent about allowing a Group vs. Group or Group vs. Array of Groups set (thanks @pyromanfo #877 #1147) 2014-08-29 01:28:43 +01:00
Allen Cook
5a3eeb8a9c Fix for group vs group within group collision (fixes #877) 2014-08-28 20:23:02 -04:00
photonstorm
36ecd81f29 Arcade Physics Body.skipQuadTree is a new boolean that if set to true when you collide the Sprite against a Group it will tell Phaser to skip using a QuadTree for that collision. This is handy if this Body is especially large.
Arcade Physics World.skipQuadTree will disable the use of all QuadTrees in collision methods, which can help performance in tightly packed scenes.
2014-08-04 13:04:11 +01:00
Charles Black
a90ab2e59b P2 bounds now collides with everything by default 2014-07-27 16:06:55 -04:00
photonstorm
2293b64c94 Removing debug / console.log output. 2014-07-09 05:49:13 +01:00