diff --git a/cocos2d/animation/animation-state.js b/cocos2d/animation/animation-state.js index 80b316f024..737b331a3b 100644 --- a/cocos2d/animation/animation-state.js +++ b/cocos2d/animation/animation-state.js @@ -171,13 +171,13 @@ var proto = AnimationState.prototype; cc.js.mixin(proto, cc.EventTarget.prototype); proto._emit = function (type, detail) { - if (this._target) { + if (this._target && this._target.isValid) { this._target.emit(type, detail); } }; proto.on = function (type, callback, target, useCapture) { - if (this._target) { + if (this._target && this._target.isValid) { if (type === 'lastframe') { this._lastframeEventOn = true; } @@ -189,7 +189,7 @@ proto.on = function (type, callback, target, useCapture) { }; proto.off = function () { - if (this._target) { + if (this._target && this._target.isValid) { if (type === 'lastframe') { if (!this.hasEventListener(type)) { this._lastframeEventOn = false; diff --git a/cocos2d/core/utils/polyfill-3d.js b/cocos2d/core/utils/polyfill-3d.js index 8f1bf0d3b8..666ceb9c6a 100644 --- a/cocos2d/core/utils/polyfill-3d.js +++ b/cocos2d/core/utils/polyfill-3d.js @@ -110,7 +110,7 @@ function getPosition () { * @param {Number} [z] - Z coordinate for position */ function setPosition (newPosOrX, y, z) { - var x; + let x; if (y === undefined) { x = newPosOrX.x; y = newPosOrX.y; @@ -121,13 +121,13 @@ function setPosition (newPosOrX, y, z) { z = z || 0 } - var pos = this._position; + let pos = this._position; if (pos.x === x && pos.y === y && pos.z === z) { return; } if (CC_EDITOR) { - var oldPosition = new cc.Vec3(pos); + let oldPosition = new cc.Vec3(pos); } pos.x = x; @@ -155,11 +155,26 @@ function getQuat () { * !#en Set rotation of node (in quaternion). * !#zh 设置该节点的 quaternion 旋转角度。 * @method setQuat - * @param {cc.Quat} quat Quaternion object represents the rotation + * @param {cc.Quat|Number} quat Quaternion object represents the rotation or the x value of quaternion + * @param {Number} y y value of quternion + * @param {Number} z z value of quternion + * @param {Number} w w value of quternion */ -function setQuat (quat) { - if (!this._quat.equals(value)) { - math.quat.copy(this._quat, value); +function setQuat (quat, y, z, w) { + let x; + if (y === undefined) { + x = quat.x; + y = quat.y; + z = quat.z; + w = quat.w; + } + + let old = this._quat; + if (old.x !== x || old.y !== y || old.z !== z || old.w !== w) { + old.x = x; + old.y = y; + old.z = z; + old.w = w; this.setLocalDirty(DirtyFlag.ROTATION); if (this._eventMask & ROTATION_ON) { diff --git a/jsb/jsb-audio.js b/jsb/jsb-audio.js index 0e68314d90..1a89d1e9d7 100644 --- a/jsb/jsb-audio.js +++ b/jsb/jsb-audio.js @@ -118,7 +118,7 @@ cc.Audio = function (src) { } path = clip._nativeAsset; } - path = cc.loader.md5Pipe.transformURL(path); + path = cc.loader.md5Pipe ? cc.loader.md5Pipe.transformURL(path) : path; return audioEngine.play2d(path, loop, volume); }; audioEngine.playMusic = function (clip, loop) {