DrawComponent¶
import { DrawComponent } from "encompass-ecs";
A DrawComponent is a special subtype of Component.
The only difference is that it implicitly contains a
layer
property so it can be ordered properly by the
World draw
function.
NOTE: It is expensive to modify the layer
property at runtime.
Properties¶
-
layer
¶ The layer at which the DrawComponent will be drawn. Lower numbers mean it is drawn earlier.
Example¶
import { DrawComponent } from "encompass-ecs";
export class CanvasComponent extends DrawComponent {
public canvas: Canvas;
public w: number;
public h: number;
}
import { CanvasComponent } from "src/components/draw/canvas";
const canvas_component = entity.add_component(CanvasComponent);
canvas_component.layer = 3;
canvas_component.w = 1280;
canvas_component.h = 720;