Jump to content

PixiJS PIXI.Spritesheet undefined


MitrB
 Share

Recommended Posts

I am trying to load a sprite sheet for PIXI js. I have a png and json file in one folder, I am pretty sure there are fine on their own. But I can't get it to load.

got this from http://pixijs.download/release/docs/PIXI.Spritesheet.html

...    
PIXI.Loader.shared.add("spritesheet.json").load(this.setup());
...

...
this.sheet = PIXI.Loader.shared.resources["spritesheet.json"].spritesheet;
console.log(this.sheet)
...

the log will say that the sheet is undefined. I think it either doesn't find the json or png file. Probably neither. I'm not sure what path "spritesheet.json" should be, relative to this file it woulde be "../assets/spritesheet.json". But that also fails.

This is my webpack config:

const path = require("path");

module.exports = {
  mode: "development",
  devtool: "eval-cheap-source-map",
  entry: "./app/index.js",
  output: {
    filename: "bundle.js",
    path: path.resolve(__dirname, "client"),
  },
  module: {
    rules: [
      {
        test: /\.(png|svg|jpg|jpeg|gif)$/i,
        loader: "file-loader",
        options: {
          name: '[name].[ext]',
        },
      },
    ],
  },
};

And this is how the bundle looks.

image.png.28e82290e197d9b38a227ef516dee5ac.png

spritesheet.png is loaded when I put it as an <img> in the html. So I know it is being received by the client.

I also get this if I console.log(this.sheet) with this.sheet = PIXI.Loader.shared.resources["spritesheet.json"];

image.thumb.png.5d203c192bfea4eb7adb58364b275cb8.png

Looks like it can't find the json file either. So I guess my question is, what are the paths of the json and png file?

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...