Skip to content

Commit 9ef0b99

Browse files
authored
Merge pull request #3426 from pandamicro/develop
Fix issues reported by QA
2 parents a20472d + f923485 commit 9ef0b99

File tree

11 files changed

+57
-32
lines changed

11 files changed

+57
-32
lines changed

cocos2d/actions/CCActionInterval.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3363,7 +3363,7 @@ cc.Animate = cc.ActionInterval.extend(/** @lends cc.Animate# */{
33633363
startWithTarget: function (target) {
33643364
cc.ActionInterval.prototype.startWithTarget.call(this, target);
33653365
if (this._animation.getRestoreOriginalFrame())
3366-
this._origFrame = target.displayFrame();
3366+
this._origFrame = target.getSpriteFrame();
33673367
this._nextFrame = 0;
33683368
this._executedLoops = 0;
33693369
},

cocos2d/clipping-nodes/CCClippingNode.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,14 @@ cc.stencilBits = -1;
4747
* @property {cc.Node} stencil - he cc.Node to use as a stencil to do the clipping.
4848
*/
4949
cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{
50-
alphaThreshold: 0,
5150
inverted: false,
51+
_alphaThreshold: 0,
5252

5353
_stencil: null,
5454
_className: "ClippingNode",
5555

56+
_originStencilProgram: null,
57+
5658
/**
5759
* Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
5860
* @param {cc.Node} [stencil=null]
@@ -61,6 +63,9 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{
6163
stencil = stencil || null;
6264
cc.Node.prototype.ctor.call(this);
6365
this._stencil = stencil;
66+
if (stencil) {
67+
this._originStencilProgram = stencil.getShaderProgram();
68+
}
6469
this.alphaThreshold = 1;
6570
this.inverted = false;
6671
this._renderCmd.initStencilBits();
@@ -154,15 +159,19 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{
154159
* @return {Number}
155160
*/
156161
getAlphaThreshold: function () {
157-
return this.alphaThreshold;
162+
return this._alphaThreshold;
158163
},
159164

160165
/**
161166
* set alpha threshold.
162167
* @param {Number} alphaThreshold
163168
*/
164169
setAlphaThreshold: function (alphaThreshold) {
165-
this.alphaThreshold = alphaThreshold;
170+
if (alphaThreshold === 1 && alphaThreshold !== this._alphaThreshold) {
171+
// should reset program used by _stencil
172+
this._renderCmd.resetProgramByStencil();
173+
}
174+
this._alphaThreshold = alphaThreshold;
166175
},
167176

168177
/**
@@ -202,6 +211,8 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{
202211
setStencil: function (stencil) {
203212
if (this._stencil === stencil)
204213
return;
214+
if (stencil)
215+
this._originStencilProgram = stencil.getShaderProgram();
205216
this._renderCmd.setStencil(stencil);
206217
},
207218

@@ -219,6 +230,9 @@ var _p = cc.ClippingNode.prototype;
219230
/** @expose */
220231
_p.stencil;
221232
cc.defineGetterSetter(_p, "stencil", _p.getStencil, _p.setStencil);
233+
/** @expose */
234+
_p.alphaThreshold;
235+
cc.defineGetterSetter(_p, "alphaThreshold", _p.getAlphaThreshold, _p.setAlphaThreshold);
222236

223237

224238
/**

cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@
124124
node._stencil._parent = node;
125125
};
126126

127+
proto.resetProgramByStencil = function () {
128+
var node = this._node;
129+
if (node._stencil) {
130+
var program = node._originStencilProgram;
131+
setProgram(node._stencil, program);
132+
}
133+
};
134+
127135
proto._onBeforeVisit = function (ctx) {
128136
var gl = ctx || cc._renderContext, node = this._node;
129137
cc.ClippingNode.WebGLRenderCmd._layer++;

cocos2d/core/base-nodes/CCNode.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
306306
* @param {Number} localZOrder
307307
*/
308308
setLocalZOrder: function (localZOrder) {
309-
this._localZOrder = localZOrder;
310309
if (this._parent)
311310
this._parent.reorderChild(this, localZOrder);
312311
cc.eventManager._setDirtyForNode(this);
@@ -1717,7 +1716,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
17171716
cc.assert(interval >= 0, cc._LogInfos.Node_schedule_2);
17181717

17191718
interval = interval || 0;
1720-
repeat = (repeat == null) ? cc.REPEAT_FOREVER : repeat;
1719+
repeat = isNaN(repeat) ? cc.REPEAT_FOREVER : repeat;
17211720
delay = delay || 0;
17221721

17231722
this.scheduler.schedule(callback, this, interval, repeat, delay, !this._running, key);

cocos2d/core/platform/CCMacro.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,10 +499,11 @@ cc.ORIENTATION_AUTO = 3;
499499

500500
/**
501501
* The limit count for concurrency http request, useful in some mobile browsers
502+
* Adjust its value with the test results based on your game, the preset value is just a placeholder
502503
* @constant
503504
* @type Number
504505
*/
505-
cc.CONCURRENCY_HTTP_REQUEST_COUNT = cc.sys.isMobile ? 9 : 0;
506+
cc.CONCURRENCY_HTTP_REQUEST_COUNT = cc.sys.isMobile ? 20 : 0;
506507

507508

508509
// ------------------- vertex attrib flags -----------------------------

cocos2d/core/platform/CCTypes.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,10 @@ _p._getB = function () {
6060
_p._setB = function (value) {
6161
this._val = (this._val & 0xffff00ff) | (value << 8);
6262
};
63-
6463
_p._getA = function () {
6564
return this._val & 0x000000ff;
6665
};
67-
68-
_p.setA = function (value) {
66+
_p._setA = function (value) {
6967
this._val = (this._val & 0xffffff00) | value;
7068
};
7169

cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
this._dirty = false;
4040
this._recursiveDirty = false;
4141

42-
this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_SPRITE_POSITION_TEXTURECOLORALPHATEST);
42+
this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_SPRITE_POSITION_TEXTURECOLOR);
4343
};
4444

4545
var proto = cc.Sprite.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype);
@@ -230,22 +230,19 @@
230230

231231
proto._setTexture = function (texture) {
232232
var node = this._node;
233-
// If batchnode, then texture id should be the same
234-
if (node._batchNode) {
235-
if (node._batchNode.texture !== texture) {
236-
cc.log(cc._LogInfos.Sprite_setTexture);
237-
return;
238-
}
239-
} else {
240-
if (node._texture !== texture) {
241-
node._textureLoaded = texture ? texture._textureLoaded : false;
242-
node._texture = texture;
243-
this._updateBlendFunc();
244-
245-
if (node._textureLoaded) {
246-
// Force refresh the render command list
247-
cc.renderer.childrenOrderDirty = true;
248-
}
233+
if (node._texture !== texture) {
234+
node._textureLoaded = texture ? texture._textureLoaded : false;
235+
node._texture = texture;
236+
237+
// Update texture rect and blend func
238+
var texSize = texture._contentSize;
239+
var rect = cc.rect(0, 0, texSize.width, texSize.height);
240+
node.setTextureRect(rect);
241+
this._updateBlendFunc();
242+
243+
if (node._textureLoaded) {
244+
// Force refresh the render command list
245+
cc.renderer.childrenOrderDirty = true;
249246
}
250247
}
251248
};

cocos2d/particle/CCParticleSystem.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,8 +1405,14 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
14051405
locModeA.tangentialAccelVar = (pszTmp) ? parseFloat(pszTmp) : 0;
14061406

14071407
// rotation is dir
1408-
var locRotationIsDir = locValueForKey("rotationIsDir", dictionary).toLowerCase();
1409-
locModeA.rotationIsDir = (locRotationIsDir != null && (locRotationIsDir === "true" || locRotationIsDir === "1"));
1408+
var locRotationIsDir = locValueForKey("rotationIsDir", dictionary);
1409+
if (locRotationIsDir !== null) {
1410+
locRotationIsDir = locRotationIsDir.toString().toLowerCase();
1411+
locModeA.rotationIsDir = (locRotationIsDir === "true" || locRotationIsDir === "1");
1412+
}
1413+
else {
1414+
locModeA.rotationIsDir = false;
1415+
}
14101416
} else if (this.emitterMode === cc.ParticleSystem.MODE_RADIUS) {
14111417
// or Mode B: radius movement
14121418
var locModeB = this.modeB;

extensions/ccui/base-classes/UIWidgetRenderCmd.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ cc.game.addEventListener(cc.game.EVENT_RENDERER_INITED, function () {
9898
};
9999

100100
proto.transform = function (parentCmd, recursive) {
101+
if (!this._transform) {
102+
this._transform = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0};
103+
this._worldTransform = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0};
104+
}
105+
101106
var node = this._node;
102107
if (node._visible && node._running) {
103108
node._adaptRenderers();

extensions/ccui/layouts/UILayoutWebGLRenderCmd.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777

7878
gl.stencilMask(mask_layer);
7979
gl.clear(gl.STENCIL_BUFFER_BIT);
80-
8180
};
8281

8382
proto._onAfterDrawStencil = function (ctx) {

0 commit comments

Comments
 (0)