Loading...
Loading...
Use this skill when creating and configuring a PixiJS v8 Application. Covers new Application() + async app.init() options (width, height, background, antialias, resolution, autoDensity, preference, resizeTo, autoStart, sharedTicker, canvas, useBackBuffer, powerPreference, eventFeatures, accessibilityOptions, gcActive, bezierSmoothness, webgl/webgpu/canvasOptions per-renderer overrides), app.stage/renderer/canvas/screen/domContainerRoot access, ResizePlugin, TickerPlugin, CullerPlugin (cullable, cullArea), custom ApplicationPlugin creation via ExtensionType.Application, start/stop lifecycle, and app.destroy() with releaseGlobalResources. Triggers on: Application, app.init, app.stage, app.renderer, app.canvas, app.screen, app.domContainerRoot, ApplicationOptions, ApplicationPlugin, ExtensionType.Application, resizeTo, preference, autoStart, sharedTicker, useBackBuffer, powerPreference, skipExtensionImports, preferWebGLVersion, preserveDrawingBuffer, cullable, CullerPlugin, app.start, app.stop, app.destroy, releaseGlobalResources.
npx skill4agent add pixijs/pixijs-skills pixijs-applicationApplicationstageapp.init()autoDetectRendererimport { Application } from "pixi.js";
const app = new Application();
await app.init({
resizeTo: window,
background: "#1099bb",
antialias: true,
preference: "webgl",
autoDensity: true,
resolution: window.devicePixelRatio,
});
document.body.appendChild(app.canvas);pixijs-core-conceptspixijs-tickerpixijs-scene-containerapp.stagepixijs-environmentsimport { Application } from "pixi.js";
const app = new Application();
await app.init({ width: 800, height: 600 });
document.body.appendChild(app.canvas);
// ... run scene, ticker drives app.render() automatically ...
app.destroy(
{ removeView: true, releaseGlobalResources: true },
{ children: true, texture: true, textureSource: true },
);new Application()app.init(options)app.canvasapp.rendererapp.screenapp.render()autoStart: falseapp.destroy(rendererDestroyOptions, stageDestroyOptions)renderer.destroy()true{ removeView: true }releaseGlobalResources: truepixijs-performanceawait app.init({
width: 800,
height: 600,
background: 0x1099bb,
backgroundAlpha: 1,
antialias: true,
resolution: window.devicePixelRatio,
autoDensity: true,
preference: "webgpu",
autoStart: true,
sharedTicker: false,
resizeTo: window,
canvas: document.querySelector("#game-canvas") as HTMLCanvasElement,
});webglwebgpucanvasOptionsapp.stage; // root Container; add all display objects here
app.renderer; // the WebGL/WebGPU/Canvas renderer instance
app.canvas; // the HTMLCanvasElement (insert it into the DOM yourself)
app.screen; // Rectangle describing the visible area in CSS pixels
app.domContainerRoot; // HTMLDivElement that holds DOMContainer overlaysapp.stageContainerpixijs-scene-containerpixijs-core-conceptspixijs-custom-renderingapp.domContainerRoot<div>DOMContainerapp.canvaspixijs-scene-dom-containerresizeToapp.resizeToresizerenderer.resize()autoDensity: trueresolution: window.devicePixelRatioawait app.init({ resizeTo: window });
app.resizeTo = document.querySelector("#game-container") as HTMLElement;
app.resize(); // immediate resize to the target's current size
app.queueResize(); // defer the resize to the next animation frame
app.cancelResize(); // drop a pending queueResizeapp.screenapp.canvas.width/heightapp.resize()app.queueResize()window.resizeapp.cancelResize()queueResizeapp.tickerapp.render()UPDATE_PRIORITY.LOWapp.start()app.stop()app.ticker.addapp.ticker.addOnceapp.ticker.add((ticker) => {
sprite.rotation += 0.01 * ticker.deltaTime;
});
app.ticker.addOnce(() => {
console.log("runs once on the next frame, then removes itself");
});
app.stop(); // pause the render loop (e.g. tab hidden)
app.start(); // resumeTickerticker.deltaTimeticker.deltaMSticker.FPSpixijs-tickeronRenderawait app.init({ autoStart: false, width: 800, height: 600 });
document.body.appendChild(app.canvas);
function frame() {
updateScene();
app.render();
requestAnimationFrame(frame);
}
frame();autoStart: falseapp.render()app.renderer.render({ container: app.stage })app.ticker.update()app.render()app.renderer.screenimport {
Application,
Container,
Sprite,
extensions,
CullerPlugin,
Rectangle,
} from "pixi.js";
extensions.add(CullerPlugin);
const app = new Application();
await app.init({ width: 800, height: 600 });
const world = new Container();
world.cullable = true; // this container is culled when its bounds leave the screen
world.cullableChildren = true; // default; set `false` to skip recursing into children
const tile = Sprite.from("tile.png");
tile.cullable = true;
world.addChild(tile);
app.stage.addChild(world);cullablecontainer.cullArea = new Rectangle(x, y, w, h)app.render()Culler.shared.cull(app.stage, app.renderer.screen)pixijs-performanceApplicationstatic initstatic destroystatic extension = ExtensionType.Applicationthisthis.rendererthis.stageimport {
Application,
ExtensionType,
extensions,
type ApplicationOptions,
} from "pixi.js";
class FpsOverlay {
public static extension = ExtensionType.Application;
public static init(this: Application, options: Partial<ApplicationOptions>) {
// runs inside app.init() after the renderer is created
// attach props/methods to `this` to expose them on the app
}
public static destroy(this: Application) {
// runs inside app.destroy() — tear down anything you attached
}
}
extensions.add(FpsOverlay);PixiMixins.ApplicationOptionsdeclare global {
namespace PixiMixins {
interface ApplicationOptions {
fpsOverlay?: { visible?: boolean };
}
}
}
await app.init({ fpsOverlay: { visible: true } });ResizePluginTickerPluginCullerPluginskipExtensionImports: trueextensions.add(ResizePlugin, TickerPlugin)const app = new Application({ width: 800, height: 600 });
document.body.appendChild(app.canvas);const app = new Application();
await app.init({ width: 800, height: 600 });
document.body.appendChild(app.canvas);Applicationinit()document.body.appendChild(app.view);document.body.appendChild(app.canvas);app.viewapp.canvasconst app = new Application();
document.body.appendChild(app.canvas);
app.init({ width: 800, height: 600 });const app = new Application();
await app.init({ width: 800, height: 600 });
document.body.appendChild(app.canvas);app.rendererapp.canvasapp.screeninit()undefined