Jump to content

bitmapfont, loader and resource already exist


Recommended Posts

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);

  .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

  <page id="0" file="IBM_BIOS-2y-16_0.png" />


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? 



Link to comment
Share on other sites

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

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.

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.


  • Recently Browsing   0 members

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