Skip to content

Commit d0f900f

Browse files
committed
Merge pull request #2407 from dingpinglv/SpriteWithoutTexture
Correct a mistake of cc.Sprite that its rendering is incorrect without texture
2 parents fcd8b87 + 512fbcc commit d0f900f

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed

cocos2d/core/base-nodes/CCNode.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,7 +1345,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
13451345
* If the cleanup parameter is not passed, it will force a cleanup. <br/>
13461346
* If the node orphan, then nothing happens.
13471347
* @function
1348-
* @param {Boolean} cleanup true if all actions and callbacks on this node should be removed, false otherwise.
1348+
* @param {Boolean} [cleanup=true] true if all actions and callbacks on this node should be removed, false otherwise.
13491349
* @see cc.Node#removeFromParentAndCleanup
13501350
*/
13511351
removeFromParent: function (cleanup) {
@@ -1360,7 +1360,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
13601360
* Removes this node itself from its parent node. <br/>
13611361
* If the node orphan, then nothing happens.
13621362
* @deprecated since v3.0, please use removeFromParent() instead
1363-
* @param {Boolean} cleanup true if all actions and callbacks on this node should be removed, false otherwise.
1363+
* @param {Boolean} [cleanup=true] true if all actions and callbacks on this node should be removed, false otherwise.
13641364
*/
13651365
removeFromParentAndCleanup: function (cleanup) {
13661366
cc.log(cc._LogInfos.Node_removeFromParentAndCleanup);
@@ -1374,7 +1374,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
13741374
* to override this method </p>
13751375
* @function
13761376
* @param {cc.Node} child The child node which will be removed.
1377-
* @param {Boolean|null} [cleanup=null] true if all running actions and callbacks on the child node will be cleanup, false otherwise.
1377+
* @param {Boolean} [cleanup=true] true if all running actions and callbacks on the child node will be cleanup, false otherwise.
13781378
*/
13791379
removeChild: function (child, cleanup) {
13801380
// explicit nil handling
@@ -1395,7 +1395,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
13951395
* If the cleanup parameter is not passed, it will force a cleanup. <br/>
13961396
* @function
13971397
* @param {Number} tag An integer number that identifies a child node
1398-
* @param {Boolean} cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise.
1398+
* @param {Boolean} [cleanup=true] true if all running actions and callbacks on the child node will be cleanup, false otherwise.
13991399
* @see cc.Node#removeChildByTag
14001400
*/
14011401
removeChildByTag: function (tag, cleanup) {
@@ -1411,7 +1411,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
14111411

14121412
/**
14131413
* Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter.
1414-
* @param {Boolean | null } cleanup
1414+
* @param {Boolean} [cleanup=true]
14151415
*/
14161416
removeAllChildrenWithCleanup: function (cleanup) {
14171417
//cc.log(cc._LogInfos.Node_removeAllChildrenWithCleanup); //TODO It should be discuss in v3.0
@@ -1422,7 +1422,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
14221422
* Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter. <br/>
14231423
* If the cleanup parameter is not passed, it will force a cleanup. <br/>
14241424
* @function
1425-
* @param {Boolean | null } cleanup true if all running actions on all children nodes should be cleanup, false otherwise.
1425+
* @param {Boolean} [cleanup=true] true if all running actions on all children nodes should be cleanup, false otherwise.
14261426
*/
14271427
removeAllChildren: function (cleanup) {
14281428
// not using detachChild improves speed here

cocos2d/core/renderer/RendererCanvas.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
173173

174174
var blendChange = (node._blendFuncStr !== "source"), alpha = (node._displayedOpacity / 255);
175175
/*if(cc.renderer.contextSession.globalAlpha !== alpha){
176-
cc.renderer.contextSession.globalAlpha = context.globalAlpha = alpha; //TODO
177-
}*/
176+
cc.renderer.contextSession.globalAlpha = context.globalAlpha = alpha; //TODO
177+
}*/
178178

179179
if (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1 || node._flippedX || node._flippedY) {
180180
context.save();
@@ -223,9 +223,9 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
223223
}
224224
} else {
225225
contentSize = node._contentSize;
226-
if(contentSize.width !== 0 && contentSize.height !== 0) {
226+
if(locTextureCoord.validRect) {
227227
curColor = node._displayedColor;
228-
context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + (node._displayedOpacity/255).toFixed(4) + ")";
228+
context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + ",1)";
229229
context.fillRect(locX * scaleX, locY * scaleY, contentSize.width * scaleX, contentSize.height * scaleY);
230230
}
231231
}
@@ -263,9 +263,9 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
263263
}
264264
} else {
265265
contentSize = node._contentSize;
266-
if(contentSize.width !== 0 && contentSize.height !== 0) {
266+
if(locTextureCoord.validRect) {
267267
curColor = node._displayedColor;
268-
context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + (node._displayedOpacity/255).toFixed(4) + ")";
268+
context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + ",1)";
269269
context.fillRect((t.tx + locX) * scaleX, (-t.ty + locY) * scaleY, contentSize.width * scaleX, contentSize.height * scaleY);
270270
}
271271
}

cocos2d/core/sprites/CCSprite.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
12691269

12701270
cc.Node.prototype.init.call(_t);
12711271
_t.dirty = _t._recursiveDirty = false;
1272-
_t._opacityModifyRGB = true;
12731272

12741273
_t._blendFunc.src = cc.BLEND_SRC;
12751274
_t._blendFunc.dst = cc.BLEND_DST;

cocos2d/core/sprites/SpritesWebGL.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ cc._tmp.WebGLSprite = function () {
8585

8686
cc.Node.prototype.init.call(_t);
8787
_t.dirty = _t._recursiveDirty = false;
88-
_t._opacityModifyRGB = true;
8988

9089
_t._blendFunc.src = cc.BLEND_SRC;
9190
_t._blendFunc.dst = cc.BLEND_DST;

0 commit comments

Comments
 (0)