import { Laya } from "Laya" ; import { Event } from "laya/events/Event" ; import { Loader } from "laya/net/Loader" ; import { Texture } from "laya/resource/Texture" ; import { Handler } from "laya/utils/Handler" ; export class Loader_ProgressAndErrorHandle { constructor ( ) { Laya . init ( 550 , 400 ) ; Laya . loader . retryNum = 0 ; var urls = [ "do not exist" , "res/fighter/fighter.png" , "res/legend/map.jpg" ] ; Laya . loader . load ( urls , Handler . create ( this , this . onAssetLoaded ) , Handler . create ( this , this . onLoading , null , false ) , Loader . TEXT ) ; Laya . loader . on ( Event . ERROR , this , this . onError ) ; } private onAssetLoaded ( texture ) { console . log ( "加载结束" ) ; } private onLoading ( progress ) { console . log ( "加载进度: " + progress ) ; } private onError ( err ) { console . log ( "加载失败: " + err ) ; } }