small optimization

This commit is contained in:
Jare Guo
2016-04-17 14:22:35 +08:00
parent 98cc058392
commit 2bc25644fd
4 changed files with 11 additions and 11 deletions
+3 -3
View File
@@ -61,9 +61,9 @@ var Color = (function () {
a = r.a;
r = r.r;
}
this.r = typeof r === 'number' ? r : 0;
this.g = typeof g === 'number' ? g : 0;
this.b = typeof b === 'number' ? b : 0;
this.r = r || 0;
this.g = g || 0;
this.b = b || 0;
this.a = typeof a === 'number' ? a : 255;
}
JS.extend(Color, ValueType);
+4 -4
View File
@@ -53,10 +53,10 @@ function Rect (x, y, w, h) {
h = x.height;
x = x.x;
}
this.x = typeof x === 'number' ? x : 0.0;
this.y = typeof y === 'number' ? y : 0.0;
this.width = typeof w === 'number' ? w : 0.0;
this.height = typeof h === 'number' ? h : 0.0;
this.x = x || 0;
this.y = y || 0;
this.width = w || 0;
this.height = h || 0;
}
JS.extend(Rect, ValueType);
require('../platform/CCClass').fastDefine('cc.Rect', Rect, ['x', 'y', 'width', 'height']);
+2 -2
View File
@@ -52,8 +52,8 @@ function Size (width, height) {
height = width.height;
width = width.width;
}
this.width = typeof width === 'number' ? width : 0;
this.height = typeof height === 'number' ? height : 0;
this.width = width || 0;
this.height = height || 0;
}
JS.extend(Size, ValueType);
require('../platform/CCClass').fastDefine('cc.Size', Size, ['width', 'height']);
+2 -2
View File
@@ -52,8 +52,8 @@ function Vec2 (x, y) {
y = x.y;
x = x.x;
}
this.x = (typeof x === 'number' ? x : 0.0);
this.y = (typeof y === 'number' ? y : 0.0);
this.x = x || 0;
this.y = y || 0;
}
JS.extend(Vec2, ValueType);
FireClass.fastDefine('cc.Vec2', Vec2, ['x', 'y']);