when i first load my webpage,my text is not show. There’s little pixel.
vers. with bug :
vers after reload the webpage :
How do i do for my text to show-up when i load my webpage the first time?
(sorry for bad english :x)
when i first load my webpage,my text is not show. There’s little pixel.
vers. with bug :
vers after reload the webpage :
How do i do for my text to show-up when i load my webpage the first time?
(sorry for bad english :x)
Hi, show us how you add text, please.
this.textConfig = [
{
color: '#ffffff',
fontSize:20,
fontFamily: "Gadugi"
},
{ color: '#ffffff',
fontSize:14,
fontFamily: "Gadugi,Georgia, serif"
}
]
this.debugText={ heroPositionX:this.add.text(-this.game.config.width, 0,"position X hero: " + this.hero.x,this.textConfig[1]), heroPositionY:this.add.text(-this.game.config.width, 20,"position Y hero: " + this.hero.y,this.textConfig[1]), information:this.add.text( -this.game.config.width, 40,"click 'C' for debug tile : " + this.showDebug,this.textConfig[1]) }; this.debugText.heroPositionX.setDepth(999); this.debugText.heroPositionY.setDepth(999); this.debugText.information.setDepth(999);
my font police is loaded in the index.html file like this :
<style>
@font-face{
font-family:Gadugi;
src:url(assets/fonts/gadugi.ttf);
}
</style>
Maybe “Gadugi” is not ready on the first page load. Can you do a test with a font already available, like “Arial” or “serif” ?
Hi @kanatos-kun,
You can integrate the font load into Phaser. In this way you ensure the availability of the font before adding the text.
You can see how it works in this example.
Regards.
Yeah thanks @Olf, @jjcapellan for the help!
Putting webfont script correct the things