Jump to content

Cannot use Premade Instance of loader in PIXI.JS


Territhekobold
 Share

Recommended Posts

So I am trying to learn more about PIXI.JS, and I have to set up an loader. I can either create my own, or I can use a premade instance that is called "shared". However when I use it I get an error message that says "Cannot read properties of undefined (reading 'shared')". What am I doing wrong?

const Application = PIXI.Application;
const app = new Application({
    width: 500,
    height: 500,
});

const loader = PIXI.Loader.shared;
loader.add('char4Texture', '/images/2.png');
loader.load(setup);`

function setup(loader, resources) {
    const char4Sprite = new PIXI.Sprite(
        resources.char4Texture
    );
    char4Sprite.y = 400;
};

I have tried to create a loader from scratch, but then I got a whole different error.

Expected outcome: Picture have been added

Actual outcome: Uncaught TypeError: Cannot read properties of undefined (reading 'shared')

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...