import type Application from "./../application/application.ts"; import Camera2d from "./../camera/camera2d.ts"; import { Color } from "./../math/color.ts"; import type World from "./../physics/world.js"; import type Light2d from "./../renderable/light2d.js"; import type Renderer from "./../video/renderer.js"; interface StageSettings { cameras: Camera2d[]; onResetEvent?: (app: Application, ...args: unknown[]) => void; onDestroyEvent?: (app: Application) => void; } /** * a default "Stage" object. * every "stage" object (title screen, credits, ingame, etc...) to be managed * through the state manager must inherit from this base class. * @category Application * @see state */ export default class Stage { /** * The list of active cameras in this stage. * Cameras will be rendered based on this order defined in this list. * Only the "default" camera will be resized when the window or canvas is resized. */ cameras: Map; /** * The list of active lights in this stage. * (Note: Canvas Rendering mode will only properly support one light per stage) * @see Light2d * @see Stage.ambientLight * @example * // create a white spot light * const whiteLight = new Light2d(0, 0, 140, "#fff", 0.7); * // and add the light to this current stage * this.lights.set("whiteLight", whiteLight); * // set a dark ambient light * this.ambientLight.parseCSS("#1117"); * // make the light follow the mouse * input.registerPointerEvent("pointermove", app.viewport, (event) => { * whiteLight.centerOn(event.gameX, event.gameY); * }); */ lights: Map; /** * an ambient light that will be added to the stage rendering * @default "#000000" * @see Light2d */ ambientLight: Color; /** * The given constructor options */ settings: StageSettings; /** * @param settings - The stage parameters * @param [settings.cameras=[]] - a list of cameras (experimental) * @param [settings.onResetEvent] - called by the state manager when reseting the object * @param [settings.onDestroyEvent] - called by the state manager before switching to another state */ constructor(settings?: Partial); /** * Object reset function * @ignore */ reset(app: Application, ...extraArgs: unknown[]): void; /** * update function * @ignore * @param dt - time since the last update in milliseconds. * @returns true if the stage needs to be redrawn */ update(dt: number): boolean; /** * draw the current stage * @ignore * @param renderer - the renderer object to draw with * @param world - the world object to draw */ draw(renderer: Renderer, world: World): void; /** * destroy function * @ignore */ destroy(app: Application): void; /** * onResetEvent function
* called by the state manager when resetting the object * this is typically where you will load a level, add renderables, etc... * @param app - the current application instance * @param args - optional arguments passed when switching state * @see state#change */ onResetEvent(app: Application, ...args: unknown[]): void; /** * onDestroyEvent function
* called by the state manager before switching to another state * @param app - the current application instance */ onDestroyEvent(app: Application): void; } export {}; //# sourceMappingURL=stage.d.ts.map