phaser-ce icon indicating copy to clipboard operation
phaser-ce copied to clipboard

interface BMFontChar wrong texture type defined

Open mcofko opened this issue 7 years ago • 4 comments

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.

mcofko avatar Aug 22 '18 14:08 mcofko

So the TypeScript definition is wrong?

samme avatar Aug 22 '18 17:08 samme

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

mcofko avatar Aug 22 '18 17:08 mcofko

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

samme avatar Aug 22 '18 18:08 samme

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

mcofko avatar Aug 24 '18 13:08 mcofko