[]clearRes好像没作用,或许我的用法不对
刚才代码路径有误,更正如下
constructor() {
super();
Laya.stage.on(Laya.Event.KEY_UP, this, this.onKeyUp);
}
onKeyUp(e: Laya.Event) {
if (e.keyCode == 65) {//A
console.log("释放资源false")
Laya.loader.clearRes("res/atlas/comp.json", false);
Laya.loader.clearRes("res/atlas/comp.png", false);
}
if (e.keyCode == 66) {//B
console.log("释放资源 true")
Laya.loader.clearRes("res/atlas/comp.json", true);
Laya.loader.clearRes("res/atlas/comp.png", true);
}
if (e.keyCode == 67) {//C
this.testimg.skin = "comp/bg.png";
}
}
点击键盘A,B并没有发现内存变化(这不是预期结果)
点击键盘C,改变skin确实找不到资源了(这是预期的结果)
constructor() {
super();
Laya.stage.on(Laya.Event.KEY_UP, this, this.onKeyUp);
}
onKeyUp(e: Laya.Event) {
if (e.keyCode == 65) {//A
console.log("释放资源false")
Laya.loader.clearRes("res/atlas/comp.json", false);
Laya.loader.clearRes("res/atlas/comp.png", false);
}
if (e.keyCode == 66) {//B
console.log("释放资源 true")
Laya.loader.clearRes("res/atlas/comp.json", true);
Laya.loader.clearRes("res/atlas/comp.png", true);
}
if (e.keyCode == 67) {//C
this.testimg.skin = "comp/bg.png";
}
}
点击键盘A,B并没有发现内存变化(这不是预期结果)
点击键盘C,改变skin确实找不到资源了(这是预期的结果)
没有找到相关结果
已邀请:
要回复问题请先登录
1 个回复
cuixueying
赞同来自: