[]官方视频教程中飞机大战 "this.addChild is not a function"

IDE Layabox1.7.20.2 beta 版
src/Game.js
//var WebGL = laya.webgl.WebGL;
//Laya.init(480, 852, WebGL);
var Game = (function(){
(function Game(){
Laya.init(480,852);
this.bg = BackGround();
Laya.stage.addChild(this.bg);
})();
})();


src/BackGround.js
var BackGround = (function(_super){
function BackGround(){
BackGround.super(this);
this.bg1 = new Laya.Sprite();
this.bg1.loadImage("war/background.png");
this.addChild(this.bg1);
}
Laya.class(BackGround,"BackGround",_super);
return BackGround;
})(Laya.Sprite);
报错
"TypeError: this.addChild is not a function    at BackGround (file:///D:/test/laya/myLaya/src/BackGround.js:6:14)    at Game (file:///D:/test/laya/myLaya/src/Game.js:6:19)    at file:///D:/test/laya/myLaya/src/Game.js:8:7    at file:///D:/test/laya/myLaya/src/Game.js:9:3"
 
已邀请:

Aar0n

赞同来自:

this.bg = new BackGround();  改成这句,这属于语法问题。不是引擎bug

要回复问题请先

商务合作
商务合作