mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-02 00:22:43 +08:00
Small issue fixes (#2617)
* Fix emit event on invalid animation issue * Support setQuat with x, y, z, w * Fix native running issue
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
+1
-1
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user