The pack
renderTexture
function renderTexture(): Pack<{ texture: RenderTextureApi }>
The render-texture pack: v2's draw verbs, each gated behind a roster object (Law 2). No options. Requires a 2D world.
Types
RenderTextureApi
interface RenderTextureApi
game.texture.
create(spec: TextureSpec): TextureHandle— Spawn a texture object and return its painter. Throws ifOffscreenCanvasis unavailable (a headless runtime without it).
TextureDef
interface TextureDef extends RenderTextureApi
What render-texture registers under 'texture' for other packs (core-2d's graphics).
readonly name: 'texture'— Its registry name.
TextureHandle
interface TextureHandle
The painter: the verbs paint a canvas, which shows from the next frame. Coordinates are texture pixels, origin top-left. Every verb returns the handle.
readonly handle: Handle— The roster handle of the sprite: move it, tint it, tween it, kill it.readonly width: number— Texture width in pixels.readonly height: number— Texture height in pixels.clear(color?: string): this— Wipe to transparent, or fill with a CSS colour.rect(x: number, y: number, w: number, h: number, color: string, alpha?: number, rot?: number): this— A filled rectangle from its top-left;rotin radians about its centre;alpha0..1, default 1.line(x0: number, y0: number, x1: number, y1: number, width: number, color: string, alpha?: number): this— A round-capped stroke;widthin pixels.poly(points: ReadonlyArray<{ x: number; y: number }>, width: number, color: string, alpha?: number, closed?: boolean): this— A stroked polyline, round joins;closedjoins the last point to the first. Fewer than two points draws nothing.fill(points: ReadonlyArray<{ x: number; y: number }>, color: string, alpha?: number): this— A filled polygon. Fewer than three points draws nothing.circle(cx: number, cy: number, r: number, color: string, alpha?: number): this— A filled disc of radiusrpixels.ring(cx: number, cy: number, r: number, thickness: number, color: string, alpha?: number): this— A stroked circle;thicknessin pixels, centred on the radius.text(str: string, x: number, y: number, opts?: { font?: string; color?: string; align?: CanvasTextAlign; baseline?: CanvasTextBaseline; alpha?: number }): this— Canvas text: a CSS font string (default '16px sans-serif'), a colour (default '#ffffff'), an alignment (default left, top).sprite(frame: number, x: number, y: number, w?: number, h?: number, opts?: { rot?: number; alpha?: number; tint?: string }): this— Paint a frame (on any atlas page, or a picture's own texture) centred at x,y;w/hdefault to the frame's size,rotin radians,tintmultiplies the pixels. A copy: an animated frame does not stay live.draw(fn: (ctx: import('@phaser-ae/kernel').PaintContext) => void): this— The escape hatch: paint with the 2D context yourself.flush(): this— Push the paint to the GPU now. Not needed: what is painted shows from the next frame on its own.destroy(): void— Remove the object; the same ashandle.kill().readonly flushes: number— Frames flushed so far.
TextureSpec
interface TextureSpec
What create spawns: the texture's size, and the sprite fields of the object that carries it.
id?: string— The object's id. Default 'texture'.width?: number— Texture width in pixels; rounded, minimum 1. Default: the screen's width. A big texture gets a texture of its own; a small one shares the atlas.height?: number— Texture height in pixels; rounded, minimum 1. Default: the screen's height.x?: number— The object's centre, world or screen units by layer. Default 0, or the screen's centre for a screen-sized texture.y?: number— The object's centre, world or screen units by layer. Default 0, or the screen's centre for a screen-sized texture.layer?: string— The draw layer; the world's default when omitted.clear?: boolean— Start transparent where nothing is painted. Default true.tags?: string[]— Tags on the object. Default ['texture'].visible?: boolean— Whether the object draws. Default true.


