[]续飞机大战

已邀请:

cuixueying

赞同来自:

建议:可以先找些js基础的课程或者文章先学习下,这样有助于你对js更好的理解
你的项目修改如下即可正常运行
Game.js
    var Game = (function(){
function Game(){
// 初始化引擎,设置了游戏的宽高
Laya.init(480,852);
Laya.stage.bgColor="#EEFFCC";
var bg = new BackGround();
Laya.stage.addChild(bg);
}
return Game;
}());
var gameInstance = new Game();
BackGround.js
var BackGround = (function (_super) {

function BackGround() {
BackGround.__super.call(this);
//创建背景1
this.bg1 = new Laya.Sprite();
//加载并显示背景图
this.bg1.loadImage("war/background.png");
//把背景1放到容器内
this.addChild(this.bg1);
//创建背景2
this.bg2 = new Laya.Sprite();
//加载并显示背景图
this.bg2.loadImage("war/background.png");
//更改背景2,放到背景1上面
this.bg2.pos(0, -852);
//把背景2放到容器内
this.addChild(this.bg2);
//创建一个帧循环,更新容器位置
};
Laya.class(BackGround,"BackGround",_super);
return BackGround;
}(Laya.Sprite));
注意:
1、如果_super是传参过来的,直接写_super.call(this)即可,如果不是直接写BackGround.__super(this)即可,两种写法(下划线个数不同。两者选其一)
2、注意大小写 this.bg = new BackGround();

要回复问题请先

商务合作
商务合作