| 网站首页 | 文章中心 | 电子书下载 | 矢量图库 | 视频教程 | 素材下载 | 程序代码下载 | JS代码 | 论坛 | 
常用软件类:
|杀毒安全 |联络聊天 |网络软件 |多媒体类 |系统工具 |图形图像 |系统工具 |应用软件 |行业软件
开发设计类:
|动画制作 |图像处理 |3D设计 |操作系统 |站长学院 |网络相关 |WEB设计 |数据库类 |程序开发
用flashMX制作迷宫游戏(2)
作者:未知    文章来源:网络    点击数:    更新时间:2006-7-13
 



★opponet层上:放置MC(opponet),取它的intance name为opponet
★player层:放上我们要移动的方块。并取mc方块的intane name为(square)
★maze boundries层:放置迷宫图MC,并取mc的intance name为maze.
★background层:背景层。不用多说。
★goal层:放置用来检测是否到达对方的起点,设mc的intane name为(goal)

到了这里,应该是差不多了,就差一个我们控制的方块怎么检测和迷宫的碰撞以及判断谁先到对方的起点。这个我们在maze这个mc中解决:

鼠标右击maze,选actions,我们会看到如下的actions:

onClipEvent (enterFrame) {//:响应mcclip的enterframe事件
if (_root.started && _root._currentframe == 1) {//:判断标志变量start=true及根目录为第一帧,则开始
with (_root.square) {//:对根目录下的square这个mc
//
// 键盘控制
if (Key.isDown(Key.DOWN)) {
_y += 1;
}
if (Key.isDown(Key.UP)) {
_y -= 1;
}
if (Key.isDown(Key.LEFT)) {
_x -= 1;
}
if (Key.isDown(Key.RIGHT)) {
_x += 1;
}
//
//检测玩家的方块是否和迷宫的墙发生碰撞
if (walls.hitTest(getBounds(_root).xMax, _y, true)) {
_x -= 1;
}
if (walls.hitTest(getBounds(_root).xMin, _y, true)) {
_x += 1;
}
if (walls.hitTest(_x, getBounds(_root).yMax, true)) {
_y -= 1;
}
if (walls.hitTest(_x, getBounds(_root).yMin, true)) {
_y += 1;
}
//
// 检测方块,要是方块和goal碰撞,就跳转到根目录下的第三帧。
if (_root.goal.hitTest(_x, getBounds(_root).yMax, true)) {
_root.gotoandstop(3);
}
}
}
}


  当然第三帧上,早就放好了我们想要的显示的内容,比如你蠃了等。

  至此,我们的迷宫游戏就全部完成了,相信你也学会了一些东西。

上一页  [1] [2] 


相关文章