Skip to content

An error occurs when using Assets.add #116

@saraOrkide

Description

@saraOrkide

When I import pixi-js and try to use the following code, it gives me the following error:
cannot read properties of undefined (reading 'format')
But if I use the direct link (https://pixijs.download/dev/pixi-legacy.min.js) it works.
I'm importing version 7.2.4, can you please guide me so that I don't have any problems while using it as an import. Thank you
ex code:
import * as PIXI from 'pixi.js';
import { Viewport as PixiViewport } from 'pixi-viewport'
const { Application, Assets, Sprite, SCALE_MODES } = PIXI;

Assets.add({
alias: 'bunny',
src: 'https://pixijs.com/assets/bunny.png',
data: {
scaleMode: SCALE_MODES.NEAREST,
},
});

async function main() {
const texture = await Assets.load('bunny');
const image = new Sprite(texture);
image.anchor.set(0.5);
image.position.set(app.screen.width / 2, app.screen.height / 2);
image.scale.set(10);
app.stage.addChild(image);
}

main();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions