[LayaAirIDE 2.0]ReferenceError: Loader is not defined 搞不懂引擎原生的也会报这个错?
onEnable() {
//戏控制脚本引用,避免每次获取组件带来不必要的性能开销
thi
s._loveControl = this.getComponent(LoveControl);
//点击提示文字,开始游戏
this.label_start.on(Laya.Event.CLICK, this, this.onTipClick);
//this._loveControl.startGame();
//点击重置按钮,重新开始
this.button_reset.on(Laya.Event.CLICK, this, this.onClickReset);
let partPath = "res/aixin_bao.part";
Laya.loader.load(partPath, Laya.Handler.create(this, this.onAssetsLoaded), null, Loader.JSON);
}
onAssetsLoaded(settings) {
// 当load数组的时候,回调函数传入的参数不再是资源,可以通过以下方法获取资源
// let settings = Laya.loader.getRes(partPath);
// 创建 Particle2D 实例
let partIns = new Laya.Particle2D(settings);
Laya.stage.addChild(partIns);
// 开始发射粒子
partIns.emitter.start();
// 播放
partIns.play();
partIns.x = Laya.stage.width / 2;
partIns.y = Laya.stage.height / 2;
}
报错如下:
ReferenceError: Loader is not defined
preload.js:55
at LoveView.onEnable (file:///D:/laya/myLaya/myZootopia/bin/js/bundle.js:683:94)
at LoveView.__proto._activeHierarchy (file:///D:/laya/myLaya/myZootopia/bin/libs/laya.core.js:21411:8)
at LoveView.__proto._processActive (file:///D:/laya/myLaya/myZootopia/bin/libs/laya.core.js:21386:8)
at LoveView.__proto._onAdded (file:///D:/laya/myLaya/myZootopia/bin/libs/laya.core.js:21475:59)
at LoveView.__proto._setParent (file:///D:/laya/myLaya/myZootopia/bin/libs/laya.core.js:21140:10)
at LoveView.__proto._setParent (file:///D:/laya/myLaya/myZootopia/bin/libs/laya.core.js:26903:31)
//戏控制脚本引用,避免每次获取组件带来不必要的性能开销
thi
s._loveControl = this.getComponent(LoveControl);
//点击提示文字,开始游戏
this.label_start.on(Laya.Event.CLICK, this, this.onTipClick);
//this._loveControl.startGame();
//点击重置按钮,重新开始
this.button_reset.on(Laya.Event.CLICK, this, this.onClickReset);
let partPath = "res/aixin_bao.part";
Laya.loader.load(partPath, Laya.Handler.create(this, this.onAssetsLoaded), null, Loader.JSON);
}
onAssetsLoaded(settings) {
// 当load数组的时候,回调函数传入的参数不再是资源,可以通过以下方法获取资源
// let settings = Laya.loader.getRes(partPath);
// 创建 Particle2D 实例
let partIns = new Laya.Particle2D(settings);
Laya.stage.addChild(partIns);
// 开始发射粒子
partIns.emitter.start();
// 播放
partIns.play();
partIns.x = Laya.stage.width / 2;
partIns.y = Laya.stage.height / 2;
}
报错如下:
ReferenceError: Loader is not defined
preload.js:55
at LoveView.onEnable (file:///D:/laya/myLaya/myZootopia/bin/js/bundle.js:683:94)
at LoveView.__proto._activeHierarchy (file:///D:/laya/myLaya/myZootopia/bin/libs/laya.core.js:21411:8)
at LoveView.__proto._processActive (file:///D:/laya/myLaya/myZootopia/bin/libs/laya.core.js:21386:8)
at LoveView.__proto._onAdded (file:///D:/laya/myLaya/myZootopia/bin/libs/laya.core.js:21475:59)
at LoveView.__proto._setParent (file:///D:/laya/myLaya/myZootopia/bin/libs/laya.core.js:21140:10)
at LoveView.__proto._setParent (file:///D:/laya/myLaya/myZootopia/bin/libs/laya.core.js:26903:31)
没有找到相关结果
已邀请:
要回复问题请先登录
0 个回复