mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 15:52:40 +08:00
small optimization
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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']);
|
||||
|
||||
@@ -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']);
|
||||
|
||||
@@ -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']);
|
||||
|
||||
Reference in New Issue
Block a user