GeneralRenderer¶
import { GeneralRenderer } from "encompass-ecs";
An GeneralRenderer is an Engine which is responsible for reading the game state in order to draw elements to the screen.
It also requires a layer, which represents the order in which it will draw to the screen.
It is an anti-pattern to modify Entities or Components from within a GeneralRenderer.
Properties¶
-
layer
¶ The layer at which the GeneralRenderer will be drawn. Lower numbers mean it is drawn earlier.
Abstracts¶
-
render
()¶ This callback is triggered by the World draw function. Place your drawing code inside this function.
Example¶
import { GeneralRenderer } from "encompass-ecs";
import { SceneComponent } from "../components/scene";
export class SceneRenderer extends GeneralRenderer {
public layer = 1;
public render() {
for (const scene_component of this.read_components(
SceneComponent
).values()) {
scene_component.scene.render();
}
}
}