SveltePixi aims to match the PixiJS API as closely as possible without doing anything too magical.
If you’re familiar with PixiJS, you should feel right at home.
You can use the Application component to create and render a PixiJS application.
All SveltePixi components should be children of Application.
Most SveltePixi components will correspond to the PixiJS class of the same name
(for example the Text component renders a PIXI.Text instance).
Textures
Some components such as Sprite will take a texture. They can be provided using PIXI.Texture.from,
just as you would in vanilla PixiJS.
PixiJS will load the texture in the background and show it when it’s ready - similar to how an img tag works.
Preloading Assets
If you have a bunch of images or other resources, you may wish to show a loading screen
until all images have finished loading (rather than have them pop in one after another).
Note: You may want to enable network throttling in your browser dev tools to actually see the loading screen - these are small images!
You can have multiple AssetsLoader components as well, which is useful
if you want to render a fallbacks at a component-level instead.
Ticker
A Ticker runs an update loop for the application.
The Application component will create one automatically, which means child
components can hook into the loop with onTick.
Accessing PixiJS Instances
Most SveltePixi components have an instance prop that
contains the underlying PixiJS instance. It’s akin to the this prop for HTML elements,
so you can bind to it if you need to access it.
Using a Custom Instance
The instance prop also lets you pass down a custom PixiJS class
that you’ve instantiated yourself. This is particularly useful
if you have a custom class (whether that be your own or from a third-party library).