From a843eb901939b959f664dcaf38d70d120c66bc8b Mon Sep 17 00:00:00 2001 From: yinkaile <501251991@qq.com> Date: Fri, 3 Nov 2017 10:32:07 +0800 Subject: [PATCH] fixed physics testAABB --- .../platform/CCPhysicsAABBQueryCallback.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/physics/platform/CCPhysicsAABBQueryCallback.js b/cocos2d/core/physics/platform/CCPhysicsAABBQueryCallback.js index a53c5639ce..06f0ac6407 100644 --- a/cocos2d/core/physics/platform/CCPhysicsAABBQueryCallback.js +++ b/cocos2d/core/physics/platform/CCPhysicsAABBQueryCallback.js @@ -1,23 +1,31 @@ function PhysicsAABBQueryCallback () { this._point = new b2.Vec2(); + this._isPoint = false; this._fixtures = []; } PhysicsAABBQueryCallback.prototype.init = function (point) { - this._point.x = point.x; - this._point.y = point.y; + if (point) { + this._isPoint = true; + this._point.x = point.x; + this._point.y = point.y; + } + else { + this._isPoint = false; + } + this._fixtures.length = 0; }; PhysicsAABBQueryCallback.prototype.ReportFixture = function (fixture) { var body = fixture.GetBody(); if (body.GetType() === b2.Body.b2_dynamicBody) { - if (this._point) { + if (this._isPoint) { if (fixture.TestPoint(this._point)) { this._fixtures.push(fixture); // We are done, terminate the query. - return false; + return false; } } else {