【轉(zhuǎn)載請注明出處】
緊接著上一篇文章createjs入門:http://www.cnblogs.com/beidan/p/7055422.html
這里來一篇小游戲?qū)崙?zhàn)篇。
效果圖:(錄屏的時(shí)候有點(diǎn)卡)
游戲整體思路實(shí)現(xiàn)
1. 實(shí)現(xiàn)一個(gè)無縫連接的背景圖,模擬出汽車在加速的狀態(tài)
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;//創(chuàng)建一個(gè)背景副本,無縫連接var copyy = -bg.height;this.copy = new createjs.Bitmap(bg);this.copy.x = 0;this.copy.y = copyy; //在畫布上y軸的坐標(biāo)為負(fù)的背景圖長//使用createjs的tick函數(shù),逐幀刷新舞臺(tái)createjs.Ticker.addEventListener("tick", tick);function tick(e) { if (e.paused !== 1) { //舞臺(tái)逐幀邏輯處理函數(shù) that.backdrop.y = that.speed +