Worth a look html5 implements a simple slot machine tutorial (game development)

Game test address: http://fsanguo.comoj.com/html5/slot/index.html Game structure index.html js folder|—Main.js |—Reel .js images folder|–image Game code: Main.js init(50,”mylegend”,600,600,main); var loadingLayer; var backLayer; var stopLayer; var startLayer; var loadIndex = 0; var imglist = {}; var btnup,btndown,btnleft,btnright; var imgData = new Array(); var mapImgList = new Array(); var mapmoveflag = “”; var MOVE_STEP = 10; var combination = new Array([1,1,5], [1,2,4], [1,5,1], [2,1,4], [2,3,3], [2,4 ,1], [2,5,4], [3,1,2], [3,4,3], [3,5,5], [4,1,2], [4,2,3 ], [4,5,1], [4,5,5], [5,1,1], [5,2,4], [5,3,2], [5,5,1], [1,1,1], [1,1,1]); var reels = new Array(); var kakes = new Array(); //Stop bottan reference array var stopBtn = new Array(); var start; var win; function main(){ imgData.push({name:”stop_up”,path:”./images/slot_stop_up.png”}); imgData.push({name:”stop_over”,path:”./images/slot_stop_over.png”}); imgData.push({name:”start”,path:”./images/slot_start.jpg”}); imgData.push({name:”kake”,path:”./images/slot_kake.png”}); imgData.push({name:”slot_back”,path:”./images/slot_back.jpg”}); imgData.push({name:”slot_ok”,path:”./images/slot_ok.png”}); imgData.push({name:”item1″,path:”./images/1.png”}); imgData.push({name:”item2″,path:”./images/2.png”}); imgData.push({name:”item3″,path:”./images/3.png”}); imgData.push({name:”item4″,path:”./images/4.png”}); imgData.push({name:”item5″,path:”./images/5.png”}); imgData.push({name:”item6″,path:”./images/6.png”}); loadingLayer = new LSprite(); loadingLayer.graphics.drawRect(1,”black”,[50, 200, 200, 20],true,”#ffffff”); addChild(loadingLayer); loadImage(); } function loadImage(){ if(loadIndex >= imgData. length){ removeChild(loadingLayer); legendLoadOver(); gameInit(); return; } loader = new LLoader(); loader.addEventListener(LEvent.COMPLETE,loadComplete); loader.load(imgData[loadIndex].path,”bitmapData”); } function loadComplete(event){ loadingLayer. graphics. clear(); loadingLayer.graphics.drawRect(1,”black”,[50, 200, 200, 20],true,”#ffffff”); loadingLayer.graphics.drawRect(1,”black”,[50, 203, 200*(loadIndex/imgData.length), 14],true,”#000000″); imglist[imgData[loadIndex].name] = loader.content; loadIndex++; loadImage(); } function gameInit(event){ var i,j,bitmap,bitmapdata,childmap; backLayer = new LSprite(); addChild(backLayer); bitmapdata = new LBitmapData(imglist[“slot_back”]); bitmap = new LBitmap(bitmapdata); backLayer.addChild(bitmap); stopLayer = new LSprite(); addChild(stopLayer); for(i=0;i<3;i++){ var reel = new Reel(combination,i); reel.x = 150 * i + 90;…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索