[LayaAir 2.0]飞机大战出现的问题注册了类New的时候报错未定义

var Game=(function(){
(function Game(){
Laya.init(400,852);
this.bg = new BackGround();
//把背景添加到舞台上显示出来
Laya.stage.addChild(this.bg); 
})(); 
  
})();
 
//循环滚动的游戏背景
var BackGround = (function(_super){
function BackGround(){
BackGround.super(this);
//创建游戏背景1
this.bg1 = new Laya.Sprite();
//加载并显示背景图
this.bg1.loadImage("war/bc.png");
//把背景1放在容器中
this.addChild(this.bg1);
//创建游戏背景2
this.bg2 = new Laya.Sprite();
//加载并显示背景图
this.bg2.loadImage("war/bc.png");
//更改背景2,放在背景1的上面
this.bg2.pos(0,-852);
//把背景2放在容器中
this.addChild(this.bg2); 
//创建一个帧循环,更新容器位置
Laya.timer.frameLoop(1,this,this.onLoop);
}
//注册类
Laya.regClass(BackGround,"BackGround",_super);
var _proto = BackGround.prototype;
_proto.onLoop = function(){
//背景容器每帧向下移动一像素
this.y +=1;
//如果背景图到了下面不可见的位置,立即调整位置到最上边
if(this.bg1.y+this.y>=852){
this.bg1.y-=852*2;
}
if(this.bg2.y+this.y>=852){
this.bg2.y-=852*2;
}
}
return BackGround;
})(Laya.Sprite);
 
 
 
 
QQ图片20191018112737.png
已邀请:

要回复问题请先

商务合作
商务合作