Answer the question
In order to leave comments, you need to log in
Error loading png in loader Pixi.js + Vue.js?
Hi everyone, I'm creating a pixie preloader in a vue app. I do everything, as in instances, very different, but a maximum of 1 png 214x214 doge is loaded, everything else is not loaded, the error can only be found in the loader in the sprite object. Here is an example code, followed by the error text. I’ll clarify that I put pictures for sprites both in assets inside src and in public.
loader
.add("a", "logo.png")
.add("b", "bbb.png")
.load(handleLoadComplete);
function handleLoadComplete() {
let texture = loader.resources.a.texture;
img = new PIXI.Sprite(texture);
img.anchor.x = 0.5;
img.anchor.y = 0.5;
app.stage.addChild(img);
app.ticker.add(animate);
};
function animate() {
img.x = app.renderer.screen.width / 2;
img.y = app.renderer.screen.height / 2;
img.rotation += 0.1;
}
Answer the question
In order to leave comments, you need to log in
Good afternoon. Specifically, in this case, the problem occurs, since the path to the image is specified relative to the project root, and not relative to the built version.
And since the project is built on the fly, to find out the relative path of the image (along with hashes and other things), instead of manually specifying the path, import the image:
import logoImagePath from './logo.png';
import bbbImagePath from './bbb.png';
loader
.add("a", logoImagePath)
.add("b", bbbImagePath)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question