Skip to content

Commit 4fdeccc

Browse files
authored
Merge pull request #3514 from pandamicro/develop
Small fixes
2 parents 0a707e9 + e9370a4 commit 4fdeccc

File tree

8 files changed

+87
-22
lines changed

8 files changed

+87
-22
lines changed

CCBoot.js

Lines changed: 64 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -801,25 +801,51 @@ cc.loader = (function () {
801801
};
802802
} else {
803803
if (xhr.overrideMimeType) xhr.overrideMimeType("text\/plain; charset=utf-8");
804-
xhr.onload = function () {
804+
var loadCallback = function () {
805+
xhr.removeEventListener('load', loadCallback);
806+
xhr.removeEventListener('error', errorCallback);
805807
if (xhr._timeoutId >= 0) {
806808
clearTimeout(xhr._timeoutId);
807809
}
810+
else {
811+
xhr.removeEventListener('timeout', timeoutCallback);
812+
}
808813
if (xhr.readyState === 4) {
809814
xhr.status === 200 ? cb(null, xhr.responseText) : cb({status:xhr.status, errorMessage:errInfo}, null);
810815
}
811816
};
812-
xhr.onerror = function () {
817+
var errorCallback = function () {
818+
xhr.removeEventListener('load', loadCallback);
819+
xhr.removeEventListener('error', errorCallback);
820+
if (xhr._timeoutId >= 0) {
821+
clearTimeout(xhr._timeoutId);
822+
}
823+
else {
824+
xhr.removeEventListener('timeout', timeoutCallback);
825+
}
813826
cb({status: xhr.status, errorMessage: errInfo}, null);
814827
};
828+
var timeoutCallback = function () {
829+
xhr.removeEventListener('load', loadCallback);
830+
xhr.removeEventListener('error', errorCallback);
831+
if (xhr._timeoutId >= 0) {
832+
clearTimeout(xhr._timeoutId);
833+
}
834+
else {
835+
xhr.removeEventListener('timeout', timeoutCallback);
836+
}
837+
cb({status: xhr.status, errorMessage: "Request timeout: " + errInfo}, null);
838+
};
839+
xhr.addEventListener('load', loadCallback);
840+
xhr.addEventListener('error', errorCallback);
815841
if (xhr.ontimeout === undefined) {
816842
xhr._timeoutId = setTimeout(function () {
817-
xhr.ontimeout();
843+
timeoutCallback();
818844
}, xhr.timeout);
819845
}
820-
xhr.ontimeout = function () {
821-
cb({status: xhr.status, errorMessage: "Request timeout: " + errInfo}, null);
822-
};
846+
else {
847+
xhr.addEventListener('timeout', timeoutCallback);
848+
}
823849
}
824850
xhr.send(null);
825851
} else {
@@ -836,10 +862,15 @@ cc.loader = (function () {
836862
xhr.open("GET", url, true);
837863
xhr.responseType = "arraybuffer";
838864

839-
xhr.onload = function () {
865+
var loadCallback = function () {
866+
xhr.removeEventListener('load', loadCallback);
867+
xhr.removeEventListener('error', errorCallback);
840868
if (xhr._timeoutId >= 0) {
841869
clearTimeout(xhr._timeoutId);
842870
}
871+
else {
872+
xhr.removeEventListener('timeout', timeoutCallback);
873+
}
843874
var arrayBuffer = xhr.response; // Note: not oReq.responseText
844875
if (arrayBuffer) {
845876
window.msg = arrayBuffer;
@@ -848,17 +879,38 @@ cc.loader = (function () {
848879
xhr.status === 200 ? cb(null, xhr.response) : cb({status:xhr.status, errorMessage:errInfo}, null);
849880
}
850881
};
851-
xhr.onerror = function(){
882+
var errorCallback = function(){
883+
xhr.removeEventListener('load', loadCallback);
884+
xhr.removeEventListener('error', errorCallback);
885+
if (xhr._timeoutId >= 0) {
886+
clearTimeout(xhr._timeoutId);
887+
}
888+
else {
889+
xhr.removeEventListener('timeout', timeoutCallback);
890+
}
852891
cb({status:xhr.status, errorMessage:errInfo}, null);
853892
};
893+
var timeoutCallback = function () {
894+
xhr.removeEventListener('load', loadCallback);
895+
xhr.removeEventListener('error', errorCallback);
896+
if (xhr._timeoutId >= 0) {
897+
clearTimeout(xhr._timeoutId);
898+
}
899+
else {
900+
xhr.removeEventListener('timeout', timeoutCallback);
901+
}
902+
cb({status: xhr.status, errorMessage: "Request timeout: " + errInfo}, null);
903+
};
904+
xhr.addEventListener('load', loadCallback);
905+
xhr.addEventListener('error', errorCallback);
854906
if (xhr.ontimeout === undefined) {
855907
xhr._timeoutId = setTimeout(function () {
856-
xhr.ontimeout();
908+
timeoutCallback();
857909
}, xhr.timeout);
858910
}
859-
xhr.ontimeout = function () {
860-
cb({status: xhr.status, errorMessage: "Request timeout: " + errInfo}, null);
861-
};
911+
else {
912+
xhr.addEventListener('timeout', timeoutCallback);
913+
}
862914
xhr.send(null);
863915
},
864916

cocos2d/core/CCScheduler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{
385385

386386
_removeUpdateFromHash:function (entry) {
387387
var self = this;
388-
element = self._hashForUpdates[entry.target.__instanceId];
388+
var element = self._hashForUpdates[entry.target.__instanceId];
389389
if (element) {
390390
// Remove list entry from list
391391
var list = element.list, listEntry = element.entry;

cocos2d/core/platform/CCConfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* @type {String}
3232
* @name cc.ENGINE_VERSION
3333
*/
34-
window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.15";
34+
window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.16";
3535

3636
/**
3737
* <p>

cocos2d/core/platform/CCInputManager.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,14 +601,18 @@ cc.inputManager = /** @lends cc.inputManager# */{
601601
this._registerKeyboardEvent();
602602

603603
//register Accelerometer event
604-
this._registerAccelerometerEvent();
604+
// this._registerAccelerometerEvent();
605605

606606
this._isRegisterEvent = true;
607607
},
608608

609609
_registerKeyboardEvent: function () {
610610
},
611611

612+
/**
613+
* Register Accelerometer event
614+
* @function
615+
*/
612616
_registerAccelerometerEvent: function () {
613617
},
614618

cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@
298298
proto.uploadData = function (f32buffer, ui32buffer, vertexDataOffset) {
299299
var node = this._node, locTexture = node._texture;
300300
if (!(locTexture && locTexture._textureLoaded && node._rect.width && node._rect.height) || !this._displayedOpacity)
301-
return false;
301+
return 0;
302302

303303
// Fill in vertex data with quad information (4 vertices for sprite)
304304
var opacity = this._displayedOpacity;

extensions/spine/CCSkeleton.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,18 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{
106106
init: function () {
107107
cc.Node.prototype.init.call(this);
108108
this._premultipliedAlpha = (cc._renderType === cc.game.RENDER_TYPE_WEBGL && cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA);
109+
},
110+
111+
onEnter: function () {
112+
cc.Node.prototype.onEnter.call(this);
109113
this.scheduleUpdate();
110114
},
111115

116+
onExit: function () {
117+
this.unscheduleUpdate();
118+
cc.Node.prototype.onExit.call(this);
119+
},
120+
112121
/**
113122
* Sets whether open debug slots.
114123
* @param {boolean} enable true to open, false to close.

extensions/spine/CCSkeletonCanvasRenderCmd.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ proto.rendering = function (wrapper, scaleX, scaleY) {
102102
proto.updateStatus = function() {
103103
this.originUpdateStatus();
104104
this._updateCurrentRegions();
105-
this._regionFlag = _ccsg.Node.CanvasRenderCmd.RegionStatus.DirtyDouble;
106-
this._dirtyFlag &= ~_ccsg.Node._dirtyFlags.contentDirty;
105+
this._regionFlag = cc.Node.CanvasRenderCmd.RegionStatus.DirtyDouble;
106+
this._dirtyFlag &= ~cc.Node._dirtyFlags.contentDirty;
107107
};
108108

109109
proto.getLocalBB = function() {

extensions/spine/CCSkeletonWebGLRenderCmd.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ proto._uploadRegionAttachmentData = function(attachment, slot, premultipliedAlph
246246
var srcIdx = i < 4 ? i % 3 : i - 2;
247247
var vx = vertices[srcIdx * 8],
248248
vy = vertices[srcIdx * 8 + 1];
249-
var x = vx * wa + vy * wb + wx,
250-
y = vx * wc + vy * wd + wy;
249+
var x = vx * wa + vy * wc + wx,
250+
y = vx * wb + vy * wd + wy;
251251
var r = vertices[srcIdx * 8 + 2] * nodeR,
252252
g = vertices[srcIdx * 8 + 3] * nodeG,
253253
b = vertices[srcIdx * 8 + 4] * nodeB,
@@ -290,8 +290,8 @@ proto._uploadMeshAttachmentData = function(attachment, slot, premultipliedAlpha,
290290
for (var i = 0, n = vertices.length; i < n; i += 8) {
291291
var vx = vertices[i],
292292
vy = vertices[i + 1];
293-
var x = vx * wa + vy * wb + wx,
294-
y = vx * wc + vy * wd + wy;
293+
var x = vx * wa + vy * wc + wx,
294+
y = vx * wb + vy * wd + wy;
295295
var r = vertices[i + 2] * nodeR,
296296
g = vertices[i + 3] * nodeG,
297297
b = vertices[i + 4] * nodeB,

0 commit comments

Comments
 (0)