1. 实现一个无缝连接的背景图,模拟出汽车在加速的状态
this.backdrop = new createjs.Bitmap(bg);this.backdrop.x = 0;this.backdrop.y = 0;this.stage.addChild(that.backdrop);this.w = bg.width;this.h = bg.height;//创建一个背景副本,无缝连接var copyy = -bg.height;this.copy = new createjs.Bitmap(bg);this.copy.x = 0;this.copy.y = copyy; //在画布上y轴的坐标为负的背景图长//使用createjs的tick函数,逐帧刷新舞台createjs.Ticker.addEventListener("tick", tick);function tick(e) { if (e.paused !== 1) {//舞台逐帧逻辑处理函数that.backdrop.y = that.speed + that.backdrop.y;
that.copy.y = that.speed + that.copy.y;if (that.copy.y > -40) {
that.backdrop.y = that.copy.y + copyy;
}if (that.copy.y > -copyy - 100) {
that.copy.y = copyy + that.backdrop.y;
}
that.stage.update(e);
}
}
查看更多关于createjs小游戏开发的实例过程的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did40773