感谢NEZ库提供的思路

This commit is contained in:
yhh
2021-06-11 16:20:01 +08:00
parent 44e2ca07e5
commit 219b90fc5d
10 changed files with 204 additions and 21 deletions

View File

@@ -6,6 +6,10 @@ module es {
}
public render(scene: Scene): void {
if (!this.renderDirty)
return;
this.renderDirty = false;
let cam = this.camera ? this.camera : scene.camera;
this.beginRender(cam);

View File

@@ -3,10 +3,13 @@ module es {
public camera: ICamera;
public readonly renderOrder: number = 0;
public shouldDebugRender: boolean = true;
protected renderDirty: boolean = true;
constructor(renderOrder: number, camera: ICamera) {
this.renderOrder = renderOrder;
this.camera = camera;
Core.emitter.addObserver(CoreEvents.renderChanged, this.onRenderChanged, this);
}
public onAddedToScene(scene: es.Scene) { }
@@ -26,6 +29,10 @@ module es {
Graphics.instance.batcher.end();
}
protected onRenderChanged() {
this.renderDirty = true;
}
public abstract render(scene: Scene): void;