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

interface BMFontChar wrong texture type defined #589

Open
mcofko opened this issue Aug 22, 2018 · 4 comments
Open

interface BMFontChar wrong texture type defined #589

mcofko opened this issue Aug 22, 2018 · 4 comments

Comments

@mcofko
Copy link

mcofko commented Aug 22, 2018

This Issue is about (pick one, ✏️ delete others)

  • A bug in the API:
    • Phaser version(s): 2.11.0
    • Live example: creating custom Phaser.BMFontChar

fontData.chars[5000] = {
x: f.x,
y: f.y,
width: f.width,
height: f.height,
xOffset: 1,
yOffset: charA.yOffset + Math.floor((charA.height - f.height) / 2),
xAdvance: f.width + 2,
kerning: [],
texture: new PIXI.Texture(font.base, new PIXI.Rectangle(f.x, f.y, f.width, f.height))
};

  • What should happen: it should accept PIXI.Texture type for texture property
  • What happens instead: it throws error, because its defined PIXI.BaseTexture type

Changing texture type property in BMFontChar interface from PIXI.BaseTexture to PIXI.Texture solves the issue.

@samme
Copy link
Collaborator

samme commented Aug 22, 2018

So the TypeScript definition is wrong?

@mcofko
Copy link
Author

mcofko commented Aug 22, 2018

I would guess so. But I did not make a thorough test. I'm not sure if changing the type breaks anything else.

@samme
Copy link
Collaborator

samme commented Aug 22, 2018

Did you get an error in the browser? What's the error message?

@mcofko
Copy link
Author

mcofko commented Aug 24, 2018

I got this error:

  • Uncaught TypeError: Cannot read property 'hasLoaded' of undefined
    at new PIXI.Sprite (phaser.js:16530)
    at Phaser.BitmapText.updateText (phaser.js:63037)
    at new Phaser.BitmapText (phaser.js:62732)
    ....
    Phaser wants to access hasLoaded property from this.texture.baseTexture, but because system is already working with BaseTexture format it of cource does not fin the property

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants