mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 15:12:18 +00:00
ArcadePhysics.collideSpriteVsGroup checks if Sprite has a body before carrying on, now safely skips sub-groups or other non-Sprite group children.
QuadTree.retrieve now checks to see if the given Sprite has a body before carrying on.
This commit is contained in:
parent
ce592d48bf
commit
713bd203ee
3 changed files with 20 additions and 2 deletions
|
@ -66,6 +66,9 @@ Version 2.0.4 - "Mos Shirare" - in development
|
|||
* AnimationManager.play will now call Animation.stop on the current animation before switching to the new one (thanks @nihakue, #713)
|
||||
* ArcadePhysics.Body.phase is checked in postUpdate to prevent it from being called multiple times in a single frame.
|
||||
* Group.setProperty will now check if the property exists before setting it, this applies to Group.setAll and anything else using setProperty internally.
|
||||
* QuadTree.retrieve now checks to see if the given Sprite has a body before carrying on.
|
||||
* ArcadePhysics.collideSpriteVsGroup checks if Sprite has a body before carrying on, now safely skips sub-groups or other non-Sprite group children.
|
||||
|
||||
|
||||
|
||||
### New Features
|
||||
|
|
|
@ -91,6 +91,12 @@ Phaser.QuadTree = function(x, y, width, height, maxObjects, maxLevels, level) {
|
|||
*/
|
||||
this.nodes = [];
|
||||
|
||||
/**
|
||||
* @property {array} _empty - Internal empty array.
|
||||
* @private
|
||||
*/
|
||||
this._empty = [];
|
||||
|
||||
this.reset(x, y, width, height, maxObjects, maxLevels, level);
|
||||
|
||||
};
|
||||
|
@ -286,9 +292,13 @@ Phaser.QuadTree.prototype = {
|
|||
*/
|
||||
retrieve: function (sprite) {
|
||||
|
||||
if (!sprite.body)
|
||||
{
|
||||
return this._empty;
|
||||
}
|
||||
|
||||
var returnObjects = this.objects;
|
||||
|
||||
// sprite.body.quadTreeIndex = this.getIndex(sprite.body);
|
||||
var index = this.getIndex(sprite.body);
|
||||
|
||||
if (this.nodes[0])
|
||||
|
|
|
@ -543,7 +543,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
*/
|
||||
collideSpriteVsGroup: function (sprite, group, collideCallback, processCallback, callbackContext, overlapOnly) {
|
||||
|
||||
if (group.length === 0)
|
||||
if (group.length === 0 || !sprite.body)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -650,6 +650,11 @@ Phaser.Physics.Arcade.prototype = {
|
|||
*/
|
||||
collideSpriteVsTilemapLayer: function (sprite, tilemapLayer, collideCallback, processCallback, callbackContext) {
|
||||
|
||||
if (!sprite.body)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this._mapData = tilemapLayer.getTiles(
|
||||
sprite.body.position.x - sprite.body.tilePadding.x,
|
||||
sprite.body.position.y - sprite.body.tilePadding.y,
|
||||
|
|
Loading…
Reference in a new issue