首先需要两个文件 png 和 fnt文件
其中fnt是png的资源文件
ps:
wwwFnt.fnt:
{"file":"www.png","frames”:{
"0":{"x":1,"y":1,"w":17,"h":25,"offX":1,"offY":0},
"1":{"x":90,"y":28,"w":8,"h":24,"offX":5,"offY":1},
"2":{"x":56,"y":1,"w":15,"h":25,"offX":2,"offY":0},
"3":{"x":20,"y":1,"w":16,"h":25,"offX":2,"offY":0},
"4":{"x":1,"y":28,"w":17,"h":25,"offX":1,"offY":0},
"5":{"x":38,"y":28,"w":16,"h":24,"offX":1,"offY":1},
"6":{"x":20,"y":28,"w":16,"h":25,"offX":1,"offY":0},
"7":{"x":73,"y":28,"w":15,"h":24,"offX":2,"offY":1},
"8":{"x":38,"y":1,"w":16,"h":25,"offX":1,"offY":0},
"9":{"x":56,"y":28,"w":15,"h":25,"offX":2,"offY":0}
}}
里面是png每个数字的相对位置 可以通过egret自带工具TextureMerger合成
使用:
var bitmapFont:egret.BitmapFont = RES.getRes("wwwFnt");
this.goldText = new egret.BitmapText();
this.goldText.font = bitmapFont;
this.goldText.text = "0";
this.goldText.$setScaleX(0.5);
this.goldText.$setScaleY(0.5);
this.goldText.x = 90;
this.goldText.y = 25;
this.addChild(this.goldText)