Jump to content

Having problems with bitmap font: Cannot read attribute.


Miyavi
 Share

Recommended Posts

Hello!

 

I've just started using Phaser, and I love it.

 

I've tried to load a bitmap font, with no success.

When loading the font, JS throws an error on phaser.min.js, saying it can't read the property attributes of "undefined". It seems the error happens on the first line, related to text, when I load the bitmapFont, although according to the examples, I'm doing this correctly.

 

Any help on this? :)

 

dkiXFhk.png

 

 

Link to comment
Share on other sites

Expand out the "Cannot read property 'attributes' of undefined" and see where it's being called. My guess is an error in (or an unrecognised) XML structure. Try loading the bitmap font found in the examples/assets folder. If that works fine with the code you've got, then it narrows it down.

Link to comment
Share on other sites

Expand out the "Cannot read property 'attributes' of undefined" and see where it's being called. My guess is an error in (or an unrecognised) XML structure. Try loading the bitmap font found in the examples/assets folder. If that works fine with the code you've got, then it narrows it down.

Yeah, indeed I just exported the font with an online tool to a .fnt, and it seems it's working fine now.

Any chance CocoonJS recognises this .fnt too, or it has to be .xml?

 

Anyway, I guess it was the format of the XML, as you said.

Link to comment
Share on other sites

I don't really know about Cocoon, sorry. It's likely the fnt file is still just xml under the hood anyway. I seem to remember the issue with Cocoon was that it doesn't have an xml parser built in - do a forum search, this topic has come up a few times and some work-arounds were batted about definitely.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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