Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An error occurs when using Assets.add #116

Open
saraOrkide opened this issue Aug 17, 2023 · 0 comments
Open

An error occurs when using Assets.add #116

saraOrkide opened this issue Aug 17, 2023 · 0 comments

Comments

@saraOrkide
Copy link

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();

@saraOrkide saraOrkide changed the title how to using Assets.add method An error occurs when using Assets.add Aug 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant