[]在微信小游戏中使用BitmapFont会导致报错.
在微信小游戏中使用BitmapFont会导致报错
在LayaIDE里是没问题的.导出成微信小游戏用"微信开发者工具"打开就报错.
堆栈:
gameThirdScriptError
undefined;at api readFile success callback function
console.error @ VM1782:1
errorReport @ WAGame.js:3
thirdErrorReport @ WAGame.js:3
(anonymous) @ WAGame.js:3
u @ WAGame.js:4
(anonymous) @ WAGame.js:4
function.setTimeout @ gamePage.html:1
(anonymous) @ WAGame.js:3
(anonymous) @ WAGame.js:13
setTimeout (async)
setTimeout @ WAGame.js:13
s @ gamePage.html:1
f.registerCallback @ gamePage.html:1
m.forEach @ gamePage.html:1
d @ gamePage.html:1
j.onmessage @ gamePage.html:1
源码如下:
//初始化微信小游戏
Laya.MiniAdpter.init();
//程序入口
Laya.init(600, 400);
//激活资源版本控制
Laya.ResourceVersion.enable("version.json", Handler.create(null, beginLoad), Laya.ResourceVersion.FILENAME_VERSION);
function beginLoad(){
let timerFont = new Laya.BitmapFont();
timerFont.loadFont('res/timerfont.fnt', Laya.Handler.create(this, () => {
Laya.Text.registerBitmapFont('Name', timerFont);
Laya.loader.load("res/atlas/comp.atlas", Handler.create(null, onLoaded));
}));
}
function onLoaded(): void {
//实例UI界面
var testUI: TestUI = new TestUI();
Laya.stage.addChild(testUI);
}
在LayaIDE里是没问题的.导出成微信小游戏用"微信开发者工具"打开就报错.
堆栈:
gameThirdScriptError
undefined;at api readFile success callback function
console.error @ VM1782:1
errorReport @ WAGame.js:3
thirdErrorReport @ WAGame.js:3
(anonymous) @ WAGame.js:3
u @ WAGame.js:4
(anonymous) @ WAGame.js:4
function.setTimeout @ gamePage.html:1
(anonymous) @ WAGame.js:3
(anonymous) @ WAGame.js:13
setTimeout (async)
setTimeout @ WAGame.js:13
s @ gamePage.html:1
f.registerCallback @ gamePage.html:1
m.forEach @ gamePage.html:1
d @ gamePage.html:1
j.onmessage @ gamePage.html:1
源码如下:
//初始化微信小游戏
Laya.MiniAdpter.init();
//程序入口
Laya.init(600, 400);
//激活资源版本控制
Laya.ResourceVersion.enable("version.json", Handler.create(null, beginLoad), Laya.ResourceVersion.FILENAME_VERSION);
function beginLoad(){
let timerFont = new Laya.BitmapFont();
timerFont.loadFont('res/timerfont.fnt', Laya.Handler.create(this, () => {
Laya.Text.registerBitmapFont('Name', timerFont);
Laya.loader.load("res/atlas/comp.atlas", Handler.create(null, onLoaded));
}));
}
function onLoaded(): void {
//实例UI界面
var testUI: TestUI = new TestUI();
Laya.stage.addChild(testUI);
}
没有找到相关结果
已邀请:
要回复问题请先登录
1 个回复
RainbowLand
赞同来自: