开发工具:
文件大小: 102kb
下载次数: 0
上传时间: 2015-01-12
详细说明: html5 拼图游戏 var setScreenWidth = 850; var setScreenHeight = 800; init(50,"mylegend",setScreenWidth,setScreenHeight,main); var backLayer,loadingLayer,imgLayer,ctrlLayer,borderLayer,overLayer,initGameLayer,recordLayer,aboutLayer; var steps = 0,time = 0; var grades; var isWin = 0; var imglist = {}; var imgData = [ {name:"garden",path:"./images/garden.jpg"}, {name:"outside",path:"./images/outside.jpg"}, {name:"button01",path:"./images/button01.png"}, {name:&qu ot;button02",path:"./images/button02.png"}, {name:"button03",path:"./images/button03.png"}, {name:"button04",path:"./images/button04.png"}, {name:"button05",path:"./images/button05.png"}, {name:"gameover_rect",path:"./images/rect.png"}, {name:"button01_over",path:"./images/button01_over.png"}, {name:"button02_over",path:"./images/button02_over.png"}, {name:"button04_over",path:"./images/button04_over.png"}, {name:"button05_over",path:"./images/button05_over.png"} ]; function main(){ loadingLayer = new LoadingSample1(); addChild(loadingLayer); LLoadManage.load( imgData, function(progress){ loadingLayer.setProgress(progress); }, function(result){ imglist = result; removeChild(loadingLayer); loadingLayer = null; //加入游戏开始时的背景 gameInitBack(); } ); } var mapLookData; function gameInit(){ mapLookData = Math.ceil(Math.random()*(1-(-1))-1); //初始化游戏层 initLayer(); //初始化背景 initBackground(); //调用随即分配地图的函数 getRandomMap(); //加入两个用户可见的变量 addText(); //加入要达到的图片 addTrueImg(); //初始化拼图块 initImg(); } var startBtn; var aboutBtn; var recordBtn; var initTextContent = ["智力大拼图","版本:v0.1"]; var initText; function gameInitBack(){ gameInit(); initGameLayer = new LSprite(); backLayer.addChild(initGameLayer); initGameLayer.graphics.drawRect(3,"dimgray",[15,30,820,620],true,"lightgray"); for(var i=0;i0 && tileData[y][x-1] == 8){ tileData[y][x-1] = tileData[y][x]; tileData[y][x] = 8; initImg(); }else if(y<2 && tileData[y+1][x] == 8){ tileData[y+1][x] = tileData[y][x]; tileData[y][x] = 8; initImg(); }else if(y>0 && tileData[y-1][x] == 8){ tileData[y-1][x] = tileData[y][x]; tileData[y][x] = 8; initImg(); } } //正确数组 var trueTileData = [ [0,1,2], [3,4,5], [6,7,8] ]; var amount; localStorage["locRecordNo"] = 0; function toWin(){ if(isWin != 1 && tileData.toString() == trueTileData.toString()){ amount = steps + time; gameOver(); writeRecord(); } } //定义输出层 var stepText; var timeText; function addText(){ stepText = new LTextField(); stepText.size = 10; stepText.color = "black"; stepText.x = 240; stepText.y = 750; overLayer.addChild(stepText); timeText = new LTextField(); timeText.size = 10; timeText.color = "black"; timeText.text = "游戏用时:"+time; timeText.x = 520; timeText.y = 750; overLayer.addChild(timeText); } var btn01; var btn02; var gameoverBitMap; var winText; var winTextContent = []; function gameOver(){ if(amount<40){ grades = "圣者"; }else if(amount>39 && amount<80){ grades = "前将军"; }else if(amount>79 && amount<160){ grades = "左将军"; }else if(amount>159 && amount<200){ grades = "右将军"; }else if(amount>199 && amount<240){ grades = "中将军"; }else if(amount>239 && amount<300){ grades = "后将军"; }else if(amount>299 && amount<500){ grades = "帐中军师"; }else if(amount>499 && amount<1000){ grades = "小小策士"; }else if(amount>999 && amount<2000){ grades = "献世小卒"; }else{ grades = "押粮步兵"; } winTextContent = ["恭喜您,您通关了","您的等级是:"+grades]; gameoverBitMap = new LBitmap(new LBitmapData(imglist["gameover_rect"])); gameoverBitMap.x = 30; gameoverBitMap.y = 100; ctrlLayer.addChild(gameoverBitMap); imgLayer.removeEventListener(LMouseEvent.MOUSE_DOWN,onDown); clearInterval(changeTime); startStatus = -1; isWin = 1; for(var i=0;i=1 && i<=4){ recordText.size = 12; recordText.color = "gray"; recordText.font = "宋体"; recordText.x = 25 + (i-1)*recordFontX; recordText.y = 80; } recordLayer.addChild(recordText); } for(var i=0;i<10;i++){ recordText = new LTextField(); recordText.weight = "bold"; recordText.font = "宋体"; recordText.color = "white"; recordText.size = 12; recordText.x = 25; recordText.y = 140 + (i-1)*recordFontY; recordText.text = i + 1; recordLayer.addChild(recordText); } for(var i=0;i<10;i++){ recordText = new LTextField(); recordText.weight = "bold"; recordText.font = "宋体"; recordText.color = "white"; recordText.size = 12; recordText.x = 25 + 1*recordFontX; recordText.y = 140 + (i-1)*recordFontY;; recordText.text = maxRunTimesArr[i+1] || ''; recordLayer.addChild(recordText); } for(var i=0;i<10;i++){ recordText = new LTextField(); recordText.weight = "bold"; recordText.font = "宋体"; recordText.color = "white"; recordText.size = 12; recordText.x = 25 + 2*recordFontX; recordText.y = 140 + (i-1)*recordFontY;; recordText.text = maxTimeArr[i+1] || ''; recordLayer.addChild(recordText); } } function getRecord(){ maxTimeArr = recordTimeArry.sort(function(a,b){return a-b;}); maxRunTimesArr = recordRunTimesArry.sort(function(a,b){return a-b;}); } ...展开收缩
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.