你的浏览器禁用了JavaScript, 请开启后刷新浏览器获得更好的体验!
输入关键字进行搜索
搜索:
没有找到相关结果
cuixueying
赞同来自:
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();
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 个回复
cuixueying
赞同来自:
你的项目修改如下即可正常运行
Game.js BackGround.js 注意:
1、如果_super是传参过来的,直接写_super.call(this)即可,如果不是直接写BackGround.__super(this)即可,两种写法(下划线个数不同。两者选其一)
2、注意大小写 this.bg = new BackGround();