|
首页 | 名片设计 CorelDRAW Illustrator AuotoCAD Painter 其他软件 Photoshop Fireworks Flash |
|
效果如下:
//----------右键菜单------------------------------------ function f1() { //右键菜单函数
getURL("http://game.tmxk.net/flasher"); } function f2() { gotoAndPlay(8); } var m1 = new ContextMenu(); //建新菜单 m1.hideBuiltInItems(); m1.customItems.push(new ContextMenuItem("我的站点", f1, true));//右键菜单项 m1.customItems.push(new ContextMenuItem("重新开始", f2, true)); _root.menu = m1; //------------------------ var str; //用数组建地图,0表示空,也是方块能移到的地方,65表示墙 str = [[0, 0, 0, 0, 0, 0, 0, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 0, 0, 0, 0, 0, 0, 0, 65, 65, 65, 65, 65, 65, 65, 65], [65, 65, 65, 65, 65, 65, 0, 0, 0, 65, 65, 65, 65, 65, 65, 65, 0, 65, 65, 65, 65, 65, 0, 65, 65, 65, 65, 65, 0, 65, 0, 65, 65, 0, 65, 65, 0, 65, 65, 65, 65, 65, 65, 65, 65], [65, 0, 0, 0, 0, 0, 0, 65, 0, 0, 0, 65, 0, 0, 0, 0, 65, 65, 65, 65, 65, 65, 0, 65, 65, 65, 65, 65, 0, 65, 0, 65, 65, 0, 65, 65, 0, 65, 65, 65, 0, 0, 0, 0, 0], [65, 0, 65, 65, 65, 65, 65, 65, 65, 65, 0, 0, 65, 65, 65, 65, 0, 0, 0, 0, 0, 65, 0, 0, 0, 0, 0, 65, 0, 65, 0, 65, 0, 0, 0, 65, 0, 65, 65, 65, 65, 65, 65, 65, 65], [65, 0, 65, 0, 0, 0, 0, 0, 0, 65, 0, 65, 0, 0, 0, 65, 0, 65, 0, 65, 0, 65, 65, 65, 65, 65, 0, 65, 0, 65, 0, 65, 0, 65, 0, 65, 0, 0, 0, 0, 0, 0, 0, 65, 65], [65, 0, 65, 0, 65, 65, 65, 65, 0, 65, 0, 65, 65, 65, 0, 65, 0, 65, 0, 65, 0, 0, 0, 0, 0, 0, 0, 65, 0, 65, 0, 65, 0, 65, 0, 0, 65, 65, 65, 65, 65, 65, 65, 65, 65], [65, 0, 65, 0, 65, 65, 0, 65, 0, 65, 65, 65, 65, 65, 0, 65, 0, 65, 0, 65, 65, 65, 65, 65, 65, 65, 65, 0, 0, 0, 0, 0, 0, 65, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65], [0, 0, 65, 0, 0, 65, 0, 65, 0, 65, 0, 0, 65, 65, 0, 65, 0, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 0, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 0, 65], [65, 0, 65, 0, 0, 65, 0, 65, 0, 65, 0, 0, 0, 0, 0, 65, 0, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 0, 65, 0, 0, 0, 0, 0, 0, 0, 65, 0, 0, 0, 0, 0, 65], [65, 0, 65, 65, 0, 65, 0, 65, 0, 65, 0, 65, 65, 0, 65, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 0, 65, 0, 65, 65, 65, 65, 65, 0, 65, 0, 65, 65, 0, 65, 65], [65, 0, 65, 65, 0, 65, 0, 65, 0, 65, 0, 65, 65, 0, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 0, 65, 65, 65, 0, 65, 65, 65, 65, 65, 0, 0, 0, 65, 65, 0, 65, 65], [65, 0, 0, 0, 0, 65, 0, 65, 0, 65, 0, 65, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 0, 0, 0, 65, 0, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 0, 65, 65], [0, 0, 65, 0, 65, 65, 0, 65, 0, 0, 0, 65, 65, 0, 65, 65, 65, 0, 0, 65, 65, 65, 65, 65, 65, 0, 65, 65, 65, 0, 0, 0, 65, 65, 65, 65, 65, 0, 0, 65, 65, 65, 0, 0, 0], [0, 65, 65, 0, 65, 65, 0, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 0, 65, 0, 0, 0, 0, 0, 0, 65, 0, 0, 0, 65, 65, 65, 65, 65, 65, 65, 65, 65, 0, 65, 65, 65, 65, 65, 0], [0, 65, 0, 0, 0, 0, 0, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 0, 65, 65, 65, 65, 65, 0, 0, 65, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 0, 65, 65, 65, 0, 65, 65, 65, 65, 65, 65, 0, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 0, 65, 65, 65, 0, 65, 65], [0, 0, 0, 0, 65, 65, 65, 0, 0, 0, 0, 0, 65, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 65, 65, 65, 65, 0, 65, 0, 65, 0, 65, 65], [65, 65, 65, 0, 65, 65, 65, 65, 0, 65, 65, 0, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 0, 65, 65, 65, 65, 65, 65, 65, 65, 0, 0, 0, 65, 65, 0, 0, 65, 0, 65, 0, 0, 65], [65, 0, 65, 0, 0, 0, 65, 65, 0, 65, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 65, 65, 0, 65, 65, 65, 65, 65, 0, 65, 65, 65, 65, 0, 65, 65, 0, 65, 65, 0, 0, 65, 0, 65], [65, 0, 65, 0, 65, 0, 65, 0, 0, 65, 65, 65, 65, 65, 65, 65, 65, 65, 0, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 65, 65, 65, 0, 65, 65, 0, 65, 65, 65, 0, 65, 0, 65], [0, 0, 65, 0, 65, 0, 65, 0, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 0, 65, 65, 65, 65, 0, 0, 65, 65, 65, 0, 65, 65, 65, 65, 65, 0, 65, 65, 0, 65, 0, 0, 0, 65, 0, 65], [0, 65, 65, 0, 65, 0, 65, 0, 65, 0, 0, 0, 65, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 65, 65, 65, 65, 0, 65, 65, 0, 65, 0, 65, 0, 65, 0, 65], [0, 65, 65, 0, 65, 0, 65, 0, 0, 65, 65, 0, 0, 0, 0, 65, 65, 65, 0, 65, 65, 65, 65, 65, 0, 65, 65, 65, 0, 0, 0, 0, 65, 0, 0, 65, 65, 0, 65, 0, 65, 0, 65, 0, 65], [0, 65, 65, 65, 65, 0, 65, 65, 65, 65, 65, 65, 65, 0, 65, 65, 0, 65, 0, 65, 0, 0, 0, 0, 0, 0, 0, 65, 65, 65, 65, 0, 0, 0, 65, 65, 65, 0, 65, 0, 65, 0, 65, 0, 65], [0, 0, 0, 0, 0, 0, 65, 65, 65, 65, 65, 65, 65, 0, 65, 65, 0, 65, 0, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 0, 0, 0, 65, 0, 65, 0, 65, 0, 0], [0, 65, 65, 65, 65, 65, 65, 0, 0, 0, 0, 0, 0, 0, 65, 0, 0, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 65, 65, 0, 65, 65, 65, 0, 65], [0, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 0, 65, 0, 65, 0, 0, 65, 65, 65, 65, 65, 65, 65, 0, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 0, 0, 0, 0, 0, 65], [0, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 0, 65, 0, 65, 65, 0, 0, 0, 65, 65, 65, 0, 65, 65, 65, 65, 0, 65, 0, 0, 0, 0, 65, 65, 65, 65, 65, 65, 0, 65], [0, 65, 0, 65, 65, 65, 65, 65, 65, 65, 65, 65, 0, 65, 65, 65, 0, 0, 65, 65, 65, 65, 65, 0, 0, 0, 0, 0, 65, 0, 65, 0, 65, 0, 65, 65, 0, 65, 0, 0, 65, 0, 65, 0, 65], [0, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 65, 0, 0, 65, 0, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 0, 65, 0, 65, 0, 65, 65, 0, 65, 65, 0, 65, 0, 65, 0, 65], [0, 65, 65, 65, 65, 65, 0, 65, 65, 65, 0, 65, 65, 0, 65, 65, 0, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 0, 0, 65, 0, 0, 0, 65, 65, 0, 65, 65, 0, 0, 0, 65, 0, 65], [0, 65, 65, 65, 65, 65, 0, 65, 65, 65, 0, 65, 65, 0, 65, 65, 0, 65, 65, 65, 65, 65, 0, 65, 65, 65, 0, 65, 0, 65, 65, 0, 65, 65, 65, 0, 0, 65, 65, 65, 65, 65, 65, 0, 65], [65, 0, 0, 0, 0, 0, 65, 65, 65, 65, 0, 65, 65, 0, 65, 0, 0, 65, 65, 65, 65, 65, 0, 65, 0, 0, 0, 65, 0, 65, 65, 0, 65, 65, 0, 0, 0, 65, 65, 0, 0, 0, 0, 0, 65], [65, 0, 65, 65, 65, 0, 0, 0, 0, 0, 0, 65, 65, 0, 65, 0, 65, 65, 0, 0, 0, 65, 0, 65, 0, 65, 65, 0, 0, 65, 0, 0, 65, 65, 0, 65, 0, 65, 65, 0, 65, 65, 65, 0, 65], [65, 0, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 0, 65, 0, 65, 65, 65, 65, 0, 0, 0, 65, 0, 65, 65, 0, 0, 0, 0, 65, 0, 0, 0, 65, 0, 65, 65, 0, 0, 0, 65, 0, 65], [65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 0, 65, 0, 65, 65, 65, 65, 65, 65, 65, 65, 0, 65, 0, 65, 65, 65, 65, 0, 0, 65, 65, 65, 0, 65, 65, 65, 65, 0, 65, 0, 65], [0, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 0, 65, 0, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 65, 65, 0, 0, 65, 65, 65, 65, 0, 0, 0, 0, 0, 0, 65, 0, 65], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 0, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 0, 65, 65, 0, 0, 65, 65, 0, 65, 65, 0, 65, 0, 0, 65], [65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 0, 65, 0, 0, 0, 65, 65, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 65, 65, 0, 0, 0, 0, 65, 65, 65, 65, 0, 65, 0, 65, 65], [65, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 65, 65, 0, 0, 65, 65, 0, 65, 65, 65, 0, 65, 65, 65, 65, 0, 65, 65, 0, 0, 65, 65, 0, 65, 0, 65, 65, 65, 0, 65, 65, 65], [65, 65, 0, 65, 65, 65, 65, 65, 65, 65, 0, 65, 65, 0, 0, 0, 0, 0, 0, 0, 65, 65, 65, 0, 65, 65, 65, 65, 0, 0, 0, 0, 65, 65, 65, 0, 65, 0, 65, 0, 0, 65, 0, 0, 0], [65, 65, 0, 65, 65, 65, 0, 0, 0, 0, 0, 65, 65, 0, 65, 65, 65, 0, 65, 65, 65, 65, 65, 0, 65, 65, 65, 65, 65, 65, 0, 65, 65, 65, 65, 0, 0, 0, 0, 0, 0, 0, 0, 65, 0], [65, 65, 0, 0, 0, 0, 65, 65, 65, 65, 65, 65, 65, 0, 65, 65, 0, 0, 0, 0, 0, 65, 65, 0, 0, 65, 65, 65, 65, 65, 65, 65, 65, 65, 0, 65, 65, 65, 0, 65, 0, 65, 65, 65, 0], [65, 65, 65, 65, 65, 0, 0, 0, 0, 0, 0, 0, 0, 65, 65, 65, 0, 65, 65, 65, 0, 65, 65, 65, 0, 0, 0, 65, 65, 65, 65, 65, 65, 65, 0, 65, 65, 65, 0, 65, 0, 65, 65, 65, 0], [65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 0, 65, 0, 0, 0, 0, 0, 65, 65, 65, 0, 0, 0, 0, 65, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 65, 65, 0, 0, 0, 0, 0, 0, 0]]; // adx = 0; //方块的横坐标 ady = 0; //方块的纵坐标 //----画边框---------------- lineStyle(3); moveTo(0, 0); lineTo(450, 0); lineTo(450, 450); lineTo(0, 450); lineTo(0, 0); //------------填充方块---------- for (var i = 0; i<45; i++) { for (var j = 0; j<45; j++) { if (str[i][j] != 0) { var num = i*45+j; _root.attachMovie("blue", "b"+num, num+1); eval("b"+num)._x = j*10; eval("b"+num)._y = i*10; } } } _root.attachMovie("red", "r", 2800);//在目的地画一红色块。 eval("r")._x = 44*10; eval("r")._y = 44*10; _root.ba.duplicateMovieClip("ball", 1); //建立小方块 ball._x = 0; ball._y = 0;//设初始位置 onEnter Frame = function () { //方向控制 if (Key.isDown(Key.UP)) { if (ady>0) { if (str[ady-1][adx] == 0) { ady = ady-1; ball._y = ball._y-10; } } } if (Key.isDown(Key.DOWN)) { if (ady<44) { if (str[ady+1][adx] == 0) { ady = ady+1; ball._y = ball._y+10; } } } if (Key.isDown(Key.RIGHT)) { if ((adx+1)%45 != 0) { if (str[ady][adx+1] == 0) { adx = adx+1; ball._x = ball._x+10; } } } if (Key.isDown(Key.LEFT)) { if (adx%45 != 0) { if (str[ady][adx-1] == 0) { adx = adx-1; ball._x = ball._x-10; } } } if (ball._x == 440 && ball._y == 440) {//结束 delete this.onEnterFrame; gotoAndStop(10); } }; stop(); //我还制了一个专门画地图的文件,可以输入数组的值。 返回类别: Flash教程 上一教程: Flash MX 2004实例制作视频教程:《火影忍者》动画片头制作(5) 下一教程: 动感水珠,Flash制作的步骤 您可以阅读与"在Flash中用二维数组建地图的迷宫游戏"相关的教程: · 在Flash中用数组建地图的贪吃蛇游戏 · Flash游戏制作:点击可弹动的小球 · Flash游戏开发系列一:游戏中的敌人(2) · Flash制作出色的空战游戏 · 精品热门FLASH游戏作品 |
快精灵印艺坊 版权所有 | 首页会员中心在线印刷在线编辑付款方式索取样品设计指南连锁门店 |