Skip to content

Commit efdd358

Browse files
author
pandamicro
committed
Fix issues:
1. Add ontimeout for xml http requests 2. CCB parser parse scale issue 3. Fix armature not rendering and not updating issue
1 parent 40cab0a commit efdd358

File tree

17 files changed

+89
-111
lines changed

17 files changed

+89
-111
lines changed

CCBoot.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ cc.AsyncPool = function (srcObj, limit, iterator, onEnd, target) {
285285
self._workingSize--;
286286
if (self.finishedSize === self.size) {
287287
var errors = self._errors.length === 0 ? null : self._errors;
288-
self.onEnd(self._onEndTarget, errors, self._results);
288+
self.onEnd(errors, self._results);
289289
return;
290290
}
291291
self._handleItem();
@@ -773,7 +773,7 @@ cc.loader = (function () {
773773
if (xhr.readyState === 4)
774774
xhr.status === 200 ? cb(null, xhr.responseText) : cb({status:xhr.status, errorMessage:errInfo}, null);
775775
};
776-
xhr.onerror = function () {
776+
xhr.onerror = xhr.ontimeout = function () {
777777
cb({status: xhr.status, errorMessage: errInfo}, null);
778778
};
779779
}
@@ -800,7 +800,7 @@ cc.loader = (function () {
800800
if(xhr.readyState === 4)
801801
xhr.status === 200 ? cb(null, xhr.response) : cb({status:xhr.status, errorMessage:errInfo}, null);
802802
};
803-
xhr.onerror = function(){
803+
xhr.onerror = xhr.ontimeout = function(){
804804
cb({status:xhr.status, errorMessage:errInfo}, null);
805805
};
806806
xhr.send(null);

cocos2d/audio/CCAudio.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,9 @@ cc.Audio.WebAudio.prototype = {
378378
request.onerror = function () {
379379
cb('request error - ' + url);
380380
};
381+
request.ontimeout = function () {
382+
cb('request timeout - ' + url);
383+
};
381384

382385
request.send();
383386
},

cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,10 @@
158158
proto.transform = function (parentCmd, recursive) {
159159
this.originTransform(parentCmd, recursive);
160160
var node = this._node;
161-
if (node._stencil && node._stencil._renderCmd)
162-
node._stencil._renderCmd.transform(this, recursive);
161+
if (node._stencil && node._stencil._renderCmd) {
162+
node._stencil._renderCmd.transform(this, true);
163+
node._stencil._dirtyFlag &= ~cc.Node._dirtyFlags.transformDirty;
164+
}
163165
};
164166

165167
proto._cangodhelpme = function (godhelpme) {

cocos2d/core/layers/CCLayer.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,8 @@ cc.Layer = cc.Node.extend(/** @lends cc.Layer# */{
4040
this._ignoreAnchorPointForPosition = true;
4141
this.setAnchorPoint(0.5, 0.5);
4242
this.setContentSize(cc.winSize);
43-
},
44-
45-
/**
46-
* Initialization of the layer, please do not call this function by yourself, you should pass the parameters to constructor to initialize a layer
47-
*/
48-
init: function () {
49-
var _t = this;
50-
_t._ignoreAnchorPointForPosition = true;
51-
_t.setAnchorPoint(0.5, 0.5);
52-
_t.setContentSize(cc.winSize);
53-
_t._cascadeColorEnabled = false;
54-
_t._cascadeOpacityEnabled = false;
55-
return true;
43+
this._cascadeColorEnabled = false;
44+
this._cascadeOpacityEnabled = false;
5645
},
5746

5847
/**

cocos2d/core/utils/BinaryLoader.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ cc.loader._str2Uint8Array = function (strData) {
7777
cc.loader.loadBinarySync = function (url) {
7878
var self = this;
7979
var req = this.getXMLHttpRequest();
80+
req.timeout = 0;
8081
var errInfo = "load " + url + " failed!";
8182
req.open('GET', url, false);
8283
var arrayInfo = null;

extensions/ccb-reader/CCBAnimationManager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ cc.BuilderAnimationManager = cc.Class.extend({
471471

472472
var containerSize = this.getContainerSize(node.getParent());
473473

474-
var absPos = cc._getAbsolutePosition(x, y, type, containerSize, propName);
474+
var absPos = cc.getAbsolutePosition(x, y, type, containerSize, propName);
475475

476476
return cc.moveTo(duration, absPos);
477477
} else if (propName === "scale") {
@@ -523,7 +523,7 @@ cc.BuilderAnimationManager = cc.Class.extend({
523523

524524
x = value[0];
525525
y = value[1];
526-
cc._getAbsolutePosition(x, y, nType, this.getContainerSize(node.getParent()), propName, _pos);
526+
cc.getAbsolutePosition(x, y, nType, this.getContainerSize(node.getParent()), propName, _pos);
527527
node._position.x = _pos.x;
528528
node._position.y = _pos.y;
529529
} else if (propName === "scale") {

extensions/ccb-reader/CCBRelativePositioning.js

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,7 @@
2424
THE SOFTWARE.
2525
****************************************************************************/
2626

27-
cc.getAbsolutePosition = function (pt, type, containerSize, propName) {
28-
if (type === CCB_POSITIONTYPE_RELATIVE_BOTTOM_LEFT) {
29-
;
30-
}
31-
else if (type === CCB_POSITIONTYPE_RELATIVE_TOP_LEFT) {
32-
pt.y = containerSize.height - pt.y;
33-
}
34-
else if (type === CCB_POSITIONTYPE_RELATIVE_TOP_RIGHT) {
35-
pt.x = containerSize.width - pt.x;
36-
pt.y = containerSize.height - pt.y;
37-
}
38-
else if (type === CCB_POSITIONTYPE_RELATIVE_BOTTOM_RIGHT) {
39-
pt.x = containerSize.width - pt.x;
40-
}
41-
else if (type === CCB_POSITIONTYPE_PERCENT) {
42-
pt.x = (containerSize.width * pt.x / 100.0);
43-
pt.y = (containerSize.height * pt.y / 100.0);
44-
}
45-
else if (type === CCB_POSITIONTYPE_MULTIPLY_RESOLUTION) {
46-
var resolutionScale = cc.BuilderReader.getResolutionScale();
47-
pt.x = pt.x * resolutionScale;
48-
pt.y = pt.y * resolutionScale;
49-
}
50-
return pt;
51-
};
52-
53-
cc._getAbsolutePosition = function (x, y, type, containerSize, propName, out) {
27+
cc.getAbsolutePosition = function (x, y, type, containerSize, propName, out) {
5428
var absPt = out || cc.p(0, 0);
5529
if (type === CCB_POSITIONTYPE_RELATIVE_BOTTOM_LEFT) {
5630
absPt.x = x;
@@ -86,6 +60,5 @@ cc.setRelativeScale = function (node, scaleX, scaleY, type, propName) {
8660
scaleY *= resolutionScale;
8761
}
8862

89-
node._scaleX = scaleX;
90-
node._scaleY = scaleY;
63+
node.setScale(scaleX, scaleY);
9164
};

extensions/ccb-reader/CCNodeLoader.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,8 @@ cc.NodeLoader = cc.Class.extend({
354354

355355
// var containerSize = ccbReader._animationManager.getContainerSize(parent);
356356
var containerSize = parent ? parent._contentSize : ccbReader._animationManager._rootContainerSize;
357-
cc._getAbsolutePosition(x, y, type, containerSize, propertyName, this._pt);
358-
node.setPosition(cc.getAbsolutePosition(this._pt, type, containerSize, propertyName)); //different to -x node.setPosition(pt);
357+
cc.getAbsolutePosition(x, y, type, containerSize, propertyName, this._pt);
358+
node.setPosition(this._pt);
359359

360360
if (ccbReader._animatedProps.indexOf(propertyName) > -1) {
361361
var baseValue = [x, y, type];
@@ -800,8 +800,7 @@ cc.NodeLoader = cc.Class.extend({
800800

801801
onHandlePropTypeScaleLock: function (node, parent, propertyName, scaleLock, ccbReader) {
802802
if (propertyName === PROPERTY_SCALE) {
803-
node._scaleX = scaleLock.x;
804-
node._scaleY = scaleLock.y;
803+
node.setScale(scaleLock.x, scaleLock.y);
805804
} else {
806805
ASSERT_FAIL_UNEXPECTED_PROPERTY(propertyName);
807806
}

extensions/cocostudio/armature/CCArmature.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{
155155
return;
156156

157157
this._renderCmd.visit(parent && parent._renderCmd);
158+
this._renderCmd._dirtyFlag = 0;
158159
},
159160

160161
addChild: function (child, localZOrder, tag) {

extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
this._RestoreRenderCmd = new cc.CustomRenderCmd(this, this._RestoreCmdCallback);
5353
this._startRenderCmd._canUseDirtyRegion = true;
5454
this._RestoreRenderCmd._canUseDirtyRegion = true;
55+
56+
this._transform = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0};
57+
this._worldTransform = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0};
5558
};
5659

5760
var proto = ccs.Armature.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype);
@@ -64,7 +67,6 @@
6467

6568
var wrapper = ctx || cc._renderContext;
6669
wrapper.save();
67-
6870
//set to armature mode
6971
wrapper._switchToArmatureMode(true, this._worldTransform, scaleX, scaleY);
7072
};
@@ -91,9 +93,9 @@
9193
var colorDirty = boneFlag & flags.colorDirty,
9294
opacityDirty = boneFlag & flags.opacityDirty;
9395
if (colorDirty)
94-
boneCmd._updateDisplayColor();
96+
boneCmd._updateDisplayColor(this._displayedColor);
9597
if (opacityDirty)
96-
boneCmd._updateDisplayOpacity();
98+
boneCmd._updateDisplayOpacity(this._displayedOpacity);
9799
if (colorDirty || opacityDirty)
98100
boneCmd._updateColor();
99101

@@ -114,7 +116,6 @@
114116

115117
proto._RestoreCmdCallback = function (wrapper) {
116118
this._cacheDirty = false;
117-
//wrapper.restore();
118119
wrapper._switchToArmatureMode(false);
119120
wrapper.restore();
120121
};
@@ -139,17 +140,16 @@
139140
if (null === selNode)
140141
continue;
141142

142-
var boneCmd = selBone._renderCmd;
143-
boneCmd._syncStatus(this);
143+
selBone._renderCmd._syncStatus(this);
144144
switch (selBone.getDisplayRenderNodeType()) {
145145
case ccs.DISPLAY_TYPE_SPRITE:
146-
selNode._renderCmd.visit(boneCmd);
146+
selNode.visit(selBone);
147147
break;
148148
case ccs.DISPLAY_TYPE_ARMATURE:
149149
selNode._renderCmd.rendering(ctx, scaleX, scaleY);
150150
break;
151151
default:
152-
selNode._renderCmd.visit(boneCmd);
152+
selNode.visit(selBone);
153153
break;
154154
}
155155
} else if (selBone instanceof cc.Node) {
@@ -182,13 +182,13 @@
182182
for (i = 0; i < len; i++) {
183183
child = children[i];
184184
if (child._localZOrder < 0)
185-
child._renderCmd.visit(cmd);
185+
child.visit(childNode);
186186
else
187187
break;
188188
}
189189
cc.renderer.pushRenderCommand(cmd);
190190
for (; i < len; i++)
191-
children[i]._renderCmd.visit(cmd);
191+
children[i].visit(childNode);
192192
} else {
193193
cc.renderer.pushRenderCommand(cmd);
194194
}

0 commit comments

Comments
 (0)