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

Pixi v5 Spritesheets don't work #5965

Closed
CloverFeywilde opened this issue Jul 28, 2019 · 2 comments
Closed

Pixi v5 Spritesheets don't work #5965

CloverFeywilde opened this issue Jul 28, 2019 · 2 comments
Labels
🤔 Question User question, similar to Help Wanted or Needs Help. These can be addressed whenever someone has tim

Comments

@CloverFeywilde
Copy link

CloverFeywilde commented Jul 28, 2019

Picture of the Error I'm Experiencing

Expected Behavior

Creating and accessing a spritesheet using PIXI 5.1 and following the documentation exactly:
http://pixijs.download/release/docs/PIXI.Spritesheet.html

PIXI.Loader.shared.add("sprites/spritesheet.json")
    .load(spriteSetup)
    .load(startup);

function spriteSetup(){
    sheet = PIXI.Loader.shared.resources["sprites/spritesheet.json"].spritesheet;
}
function startup(){
    bunny = new PIXI.Sprite(sheet.textures["bunny.png"]);
}

Current Behavior

The console.log is returning "sheet is undefined". I look in the console and
'PIXI.Loader.shared.resources["sprites/spritesheet.json"]'
returns an object. but the .spritesheet property doesn't exist. This is how the official documentation says to load in spritesheets, right? Am I missing something obvious here, or does pixi no longer have the ability to load sprites from a spritesheet?

Possible Solution

Steps to Reproduce

  1. Download what I've written here: https://github.com/Forleafe/FaerieHeart
  2. Run index.html
  3. look at the console.log

Environment

  • pixi.js version: 5.1.0
  • Browser & Version: Firefox 68.01
  • OS & Version: Ubuntu 18.04
@themoonrat themoonrat added 🤔 Question User question, similar to Help Wanted or Needs Help. These can be addressed whenever someone has tim Version: v5.x labels Jul 29, 2019
@themoonrat
Copy link
Member

This is because you're trying to run the html file from your PC; browsers don't like that. You must run it through a web server.
npm i -g http-server@0.9.0
then
npm run http-server
in the directory where your index.html file is. Then it all works fine for me

@CloverFeywilde
Copy link
Author

CloverFeywilde commented Jul 30, 2019

This is because you're trying to run the html file from your PC; browsers don't like that. You must run it through a web server.
npm i -g http-server@0.9.0
then
npm run http-server
in the directory where your index.html file is. Then it all works fine for me

@themoonrat
Ah you're totally right, thanks babe. ;; I was actually running http-server already, but the problem was that firefox by default doesn't open local files in localhost:8080 like it used to, so I actually had to navigate to "localhost:8080" in the URL bar for everything to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤔 Question User question, similar to Help Wanted or Needs Help. These can be addressed whenever someone has tim
Projects
None yet
Development

No branches or pull requests

2 participants