genrogdev Posted February 23, 2019 Share Posted February 23, 2019 I'm currently learning pixi.js and have hit a snag with the loader when attempting to load a bitmap font ERROR Error: Resource named "/fonts/IBM_BIOS-2y-16_0.png" already exists. I get this after loading the associated xml file and made absolutely sure the loader only gets called once by setting breakpoints and stepping trough the program this.loader = new PIXI.Loader('game-assets', 8); this.loader .use(PIXI.BitmapFontLoader.use) .add('fonts/IBM_BIOS-2y-16.xml') .load((_loader, context) => { // snipped for simplicity }); }); The fact that it reads the texture once as verified by the devtool network tab despite not asking for it makes me confident the xml file is being processed correctly, and I also made sure that it does only have one single texture associated with it and referenced in the file <pages> <page id="0" file="IBM_BIOS-2y-16_0.png" /> </pages> After following the steps I can see that it only makes a single call to `BitmapText.add(... )` at `@pixi/text-bitmap/lib/text-bitmap.es.js : 830` for the texture and throws the error there. Tracing it further I noticed that after the BitmapFontLoader has loaded the xml file, the `resource-loader/lib/Resource.js` file eventually calls `this._loadElement('image');`, and then BitmapFontLoader tries to load the same texture again So basically the standard loader gets in between the sequence of the bitmap loader, the question is why? Did I misunderstand how to use loader plugins as seen above? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted February 23, 2019 Share Posted February 23, 2019 Bitmap fonts work fine in a demo: https://pixijs.io/examples/?v=dev#/demos/text-demo.js I modified maxQueue just to check that it works: var loader = new PIXI.Loader(undefined, 5); I guess there's something on your side that prevents me from reproducing it. Any ideas? Quote Link to comment Share on other sites More sharing options...
genrogdev Posted February 23, 2019 Author Share Posted February 23, 2019 After getting a good night sleep I was able to debug and resolve it in about 5 mins. The issue was that PIXI.loader had been moved to PIXI.Loader.shared, when you load the pixi file directly off the cdn it will throw an error and tell you, but since I'm working in a typescript dev environment I couln't get PIXI.loader to work in the first place as the transpiler would throw a not found error. Unfortunatly the typings file doesn't have a @depricated annotation here so I had to go over the API documentation. I suspect most of the documentation and examples is based on a previous version where PIXI.loader was in use, and thus didn't help much. I looked up the loader API and found that you could instantiate a new loader instance and I guess I couldn't get the BitmapFontLoader middleware to register properly, and no documentation on how to load it. Now that I know how the default global loader works, and where its located, I guess I should look up how it registers BitmapFontLoader and other middleware to learn how to do so Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.