Files
esengine/source/src/Debug/Debug.ts

25 lines
839 B
TypeScript
Raw Normal View History

2020-07-23 11:00:46 +08:00
module es {
export class Debug {
private static _debugDrawItems: DebugDrawItem[] = [];
2020-07-09 16:16:04 +08:00
2020-07-28 16:25:20 +08:00
public static drawHollowRect(rectanle: Rectangle, color: number, duration = 0) {
2020-07-23 11:00:46 +08:00
this._debugDrawItems.push(new DebugDrawItem(rectanle, color, duration));
}
2020-07-09 16:16:04 +08:00
2020-07-28 16:25:20 +08:00
public static render() {
if (this._debugDrawItems.length > 0) {
2020-07-23 11:00:46 +08:00
let debugShape = new egret.Shape();
2020-07-28 16:25:20 +08:00
if (Core.scene) {
Core.scene.addChild(debugShape);
2020-07-23 11:00:46 +08:00
}
2020-07-09 16:16:04 +08:00
2020-07-28 16:25:20 +08:00
for (let i = this._debugDrawItems.length - 1; i >= 0; i--) {
2020-07-23 11:00:46 +08:00
let item = this._debugDrawItems[i];
if (item.draw(debugShape))
this._debugDrawItems.removeAt(i);
}
2020-07-09 16:16:04 +08:00
}
}
}
2020-07-23 11:00:46 +08:00
}