Skip to content

Commit e77d67b

Browse files
committed
Fixed three bugs that it sets to other value when the parameter is 0.
1 parent 0dc16b3 commit e77d67b

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

cocos2d/core/platform/CCTypes.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ cc.Color = function (r, g, b, a) {
3636
this.r = r || 0;
3737
this.g = g || 0;
3838
this.b = b || 0;
39-
this.a = a || 255;
39+
this.a = (a == null) ? 255 : a;
4040
};
4141

4242
/**
@@ -66,8 +66,8 @@ cc.color = function (r, g, b, a) {
6666
if (typeof r === "string")
6767
return cc.hexToColor(r);
6868
if (typeof r === "object")
69-
return {r: r.r, g: r.g, b: r.b, a: r.a || 255};
70-
return {r: r, g: g, b: b, a: a || 255 };
69+
return {r: r.r, g: r.g, b: r.b, a: (r.a == null) ? 255 : r.a};
70+
return {r: r, g: g, b: b, a: (r.a == null) ? 255 : r.a};
7171
};
7272

7373
/**

cocos2d/core/platform/CCTypesWebGL.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,10 @@ cc._tmp.WebGLColor = function () {
7474
this._rU8[0] = r || 0;
7575
this._gU8[0] = g || 0;
7676
this._bU8[0] = b || 0;
77-
this._aU8[0] = a || 255;
77+
this._aU8[0] = (a == null) ? 255 : a;
7878

79-
if (a === undefined) {
79+
if (a === undefined)
8080
this.a_undefined = true;
81-
}
8281
};
8382
/**
8483
* @constant

extensions/ccui/base-classes/UIWidget.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{
972972
this._positionPercent.x = 0;
973973
this._positionPercent.y = 0;
974974
} else {
975-
if (posY) {
975+
if (posY == undefined) {
976976
this._positionPercent.x = pos / pSize.width;
977977
this._positionPercent.y = posY / pSize.height;
978978
} else {

0 commit comments

Comments
 (0)