Merge pull request #2274 from pandamicro/v1.8

issue fixes
This commit is contained in:
Jare Guo
2018-01-18 18:41:55 +08:00
committed by GitHub
4 changed files with 36 additions and 12 deletions
+12 -9
View File
@@ -1357,20 +1357,23 @@ var Node = cc.Class({
_hitTest (point, listener) {
var w = this.width,
h = this.height;
var rect = cc.rect(0, 0, w, h);
h = this.height,
pt = point;
var Camera = cc.Camera;
if (Camera && Camera.main && Camera.main.containsNode(this)) {
point = Camera.main.getCameraToWorldPoint(point);
pt = Camera.main.getCameraToWorldPoint(pt);
}
var trans = this.getNodeToWorldTransform();
cc._rectApplyAffineTransformIn(rect, trans);
var left = point.x - rect.x,
right = rect.x + rect.width - point.x,
bottom = point.y - rect.y,
top = rect.y + rect.height - point.y;
var trans = this.getWorldToNodeTransform();
pt = cc.pointApplyAffineTransform(pt, trans);
pt.x += this._anchorPoint.x * w;
pt.y += this._anchorPoint.y * h;
var left = pt.x,
right = w - pt.x,
bottom = pt.y,
top = h - pt.y;
if (left >= 0 && right >= 0 && top >= 0 && bottom >= 0) {
if (listener && listener.mask) {
var mask = listener.mask;
+10 -2
View File
@@ -160,6 +160,7 @@ HashTimerEntry.put = function (entry) {
* @extends cc.Class
*/
function CallbackTimer () {
this._lock = false;
this._scheduler = null;
this._elapsed = -1;
this._runForever = false;
@@ -176,6 +177,7 @@ function CallbackTimer () {
var proto = CallbackTimer.prototype;
proto.initWithCallback = function (scheduler, callback, target, seconds, repeat, delay) {
this._lock = false;
this._scheduler = scheduler;
this._target = target;
this._callback = callback;
@@ -241,8 +243,10 @@ proto.getCallback = function(){
};
proto.trigger = function () {
if (this._target && this._callback){
if (this._target && this._callback) {
this._lock = true;
this._callback.call(this._target, this._elapsed);
this._lock = false;
}
};
@@ -256,7 +260,7 @@ CallbackTimer.get = function () {
return _timers.pop() || new CallbackTimer();
};
CallbackTimer.put = function (timer) {
if (_timers.length < MAX_POOL_SIZE) {
if (_timers.length < MAX_POOL_SIZE && !timer._lock) {
timer._scheduler = timer._target = timer._callback = null;
_timers.push(timer);
}
@@ -572,6 +576,10 @@ cc.Scheduler = cc._Class.extend({
timer = CallbackTimer.get();
timer.initWithCallback(this, callback, target, interval, repeat, delay);
element.timers.push(timer);
if (this._currentTarget === element && this._currentTargetSalvaged) {
this._currentTargetSalvaged = false;
}
},
/**
+1 -1
View File
@@ -1716,7 +1716,7 @@ _ccsg.Node = cc.Class({
* @return {cc.AffineTransform}
*/
getWorldToNodeTransform: function () {
return cc.affineTransformInvert(this.getNodeToWorldTransform());
return cc.affineTransformInvertIn(this.getNodeToWorldTransform());
},
/**
@@ -374,6 +374,19 @@ cc.affineTransformInvert = function (t) {
tx: determinant * (t.c * t.ty - t.d * t.tx), ty: determinant * (t.b * t.tx - t.a * t.ty)};
};
cc.affineTransformInvertIn = function (t) {
var a = t.a, b = t.b, c = t.c, d = t.d;
var determinant = 1 / (a * d - b * c);
var tx = t.tx, ty = t.ty;
t.a = determinant * d;
t.b = -determinant * b;
t.c = -determinant * c;
t.d = determinant * a;
t.tx = determinant * (c * ty - d * tx);
t.ty = determinant * (b * tx - a * ty);
return t;
};
/**
* !#en Put the invert transform of an AffineTransform object into the out AffineTransform object.
* !#zh 求逆矩阵并存入用户传入的矩阵对象参数。