新增Debug辅助Insist
This commit is contained in:
46
source/src/Debug/Debug.ts
Normal file
46
source/src/Debug/Debug.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
module es {
|
||||
export enum LogType {
|
||||
error,
|
||||
warn,
|
||||
log,
|
||||
info,
|
||||
trace
|
||||
}
|
||||
|
||||
export class Debug {
|
||||
public static warnIf(condition: boolean, format: string, ...args: any[]) {
|
||||
if (condition)
|
||||
this.log(LogType.warn, format, args);
|
||||
}
|
||||
|
||||
public static warn(format: string, ...args: any[]) {
|
||||
this.log(LogType.warn, format, args);
|
||||
}
|
||||
|
||||
public static error(format: string, ...args: any[]) {
|
||||
this.log(LogType.error, format, args);
|
||||
}
|
||||
|
||||
public static log(type: LogType, format: string, ...args: any[]) {
|
||||
switch(type) {
|
||||
case LogType.error:
|
||||
console.error(`${type}: ${StringUtils.format(format, args)}`);
|
||||
break;
|
||||
case LogType.warn:
|
||||
console.warn(`${type}: ${StringUtils.format(format, args)}`);
|
||||
break;
|
||||
case LogType.log:
|
||||
console.log(`${type}: ${StringUtils.format(format, args)}`);
|
||||
break;
|
||||
case LogType.info:
|
||||
console.info(`${type}: ${StringUtils.format(format, args)}`);
|
||||
break;
|
||||
case LogType.trace:
|
||||
console.trace(`${type}: ${StringUtils.format(format, args)}`);
|
||||
break;
|
||||
default:
|
||||
throw new Error('argument out of range');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ module es {
|
||||
* 我们在这里存储了各种系统的默认颜色,如对撞机调试渲染、Debug.drawText等。
|
||||
* 命名方式尽可能采用CLASS-THING,以明确它的使用位置
|
||||
*/
|
||||
export class Debug {
|
||||
export class DebugDefault {
|
||||
public static debugText: number = 0xffffff;
|
||||
|
||||
public static colliderBounds: number = 0xffffff * 0.3;
|
||||
|
||||
Reference in New Issue
Block a user