[LayaAir 2.0]Laya.Loader.getRes("xxx.png")取出来的资源为什么是Texture2D,不是Texture
两张图片,一张取出来是Texture。 另一张却是Texture2D
版本 Laya 2.4.0.1600
这是一个图集动画,第一次加载显示没问题,是在第二次的时候出了问题。
播放流程:第一次动画播放完后,会把图集资源清理掉,
for (let imgName of imgAry.imgs) {
Laya.loader.cancelLoadByUrl(imgName);
Laya.loader.clearTextureRes(imgName);
Laya.loader.clearRes(imgName);
}
也会调用Laya.loader.cancelLoadByUrl(imgName);清理掉当前动画一些没有加载完成的图片资源。但是下次再进来播放会导致取出来的不是Texture 而是 Texture2D
if (!tex.getIsReady()) {
tex.once(Event.READY, this, this.drawImage, [tex, x, y, width, height]);
}
导致 tex 找不到 getIsReady 方法报错
报错堆栈
TypeError: tex.getIsReady is not a function at Graphics.loadImage (file:///D:/zxl/2.0_stable/lfGame2.0/bin/libs/laya.core.js:11477:26) at Function.createFrames (file:///D:/zxl/2.0_stable/lfGame2.0/bin/libs/laya.core.js:23134:23) at Animation.loadImages (file:///D:/zxl/2.0_stable/lfGame2.0/bin/libs/laya.core.js:23020:107) at Function.initAnimation (file:///D:/zxl/2.0_stable/lfGame2.0/bin/js/bundle.js:4020:24) at Function.playAnimation (file:///D:/zxl/2.0_stable/lfGame2.0/bin/js/bundle.js:3988:28) at Pry_floor.playShuiJingLoop (file:///D:/zxl/2.0_stable/lfGame2.0/bin/js/bundle.js:11677:28) at Pry_floor.<anonymous> (file:///D:/zxl/2.0_stable/lfGame2.0/bin/js/bundle.js:11663:22) at EventHandler.run (file:///D:/zxl/2.0_stable/lfGame2.0/bin/libs/laya.core.js:986:38) at Animation.event (file:///D:/zxl/2.0_stable/lfGame2.0/bin/libs/laya.core.js:1038:68) at Animation._frameLoop (file:///D:/zxl/2.0_stable/lfGame2.0/bin/libs/laya.core.js:20275:30)
要回复问题请先登录
4 个回复
Nevermore
赞同来自:
临时这样解决了下··
Aar0n
赞同来自:
Nevermore
赞同来自:
在控制台用 Laya.Resource._urlResourcesMap
查出来的都是Texture2D 单独用Laya.Loader.getRes(xx)取出来的也是 Texture2D
Nevermore
赞同来自: