The pack
core2d
function core2d(): Pack<Core2dApi>
The 2D core. No options: everything it composes is configured by its defaults, or by naming that pack in the manifest.
Types
Core2dApi
interface Core2dApi
What core-2d puts on the game.
text(text: string | number, x: number, y: number, style?: TextStyle): Text— Text on screen, centered onx, yby default:game.text('Score 0', 640, 40, { size: 32, stroke: { color: '#000', width: 2 } }).readonly background: Background— What is behind everything: a color, a gradient, stars, a picture.graphics(spec?: GraphicsSpec): Graphics— A picture to draw on while the game runs; with no size it covers the screen.
Graphics
type Graphics = TextureHandle
A picture you draw on while the game runs: trails, glows, meters, lines between things. Draw with the verbs or with
the ordinary 2D context in draw(ctx => …); what you draw shows from the next frame. It keeps what was drawn until
clear(). Coordinates are its own pixels, origin top-left (for a screen-sized one, screen pixels).
GraphicsSpec
interface GraphicsSpec
Where game.graphics goes and how big it is. With no size it covers the screen.
id?: string— Its id, for inspect. Default'graphics'.width?: number— Width in pixels. Default the screen's width.height?: number— Height in pixels. Default the screen's height.x?: number— Its center. Default the screen's center when it covers the screen, else 0.y?: number— Its center. Default the screen's center when it covers the screen, else 0.layer?: string— The layer. Default the world's, so it moves with the camera;'hud'keeps it on screen.


