Flash教程:走迷宫游戏的制作基础实例

来源:岁月联盟 编辑:zhu 时间:2007-10-12
Flash教程:走迷宫游戏的制作基础实例内容简介:通过一个简单实例,让大家掌握迷宫游戏的制作基

通过一个简单实例,让大家掌握迷宫游戏的制作基础。下面给大家说说制作的过程。

首先看演示效果和源文件。

制作步骤:

启动Flash 8 然后新建立文档,调整属性,设置如下。

Flash教程:走迷宫游戏的制作基础实例

制作一个在迷宫,影片剪辑类型,名称为path,在这里设置了两个图层,做好一个简单路径,设置如下。

Flash教程:走迷宫游戏的制作基础实例

制作一个在迷宫中移动的物体,影片剪辑类型,名称为minion,在这里只简单制作一个小三角图,设置如下。

Flash教程:走迷宫游戏的制作基础实例

在主场景第一帧,添加下面代码。

attachMovie("path","path",_root.getNextHighestDepth());
waypoint_x = new Array(40, 140, 140, 220, 220, 80, 80, 340, 340, 420, 420);
waypoint_y = new Array(140, 140, 60, 60, 240, 240, 320, 320, 100, 100, -20);
delay = 25;
new_monster = 0;
monsters_placed = 0;
onEnterFrame = function () {
 if (monsters_placed<25) {
  new_monster++;
 }
 if (new_monster == delay) {
  monsters_placed++;
  new_monster = 0;
  min = attachMovie("minion", "minion"+_root.getNextHighestDepth(), _root.getNextHighestDepth(), {_x:40, _y:-20});
  min.point_to_reach = 0;
  min.speed = 1;
  min.onEnterFrame = function() {
   dist_x = waypoint_x[this.point_to_reach]-this._x;
   dist_y = waypoint_y[this.point_to_reach]-this._y;
   if ((Math.abs(dist_x)+Math.abs(dist_y))<1) {
    this.point_to_reach++;
   }
   angle = Math.atan2(dist_y, dist_x);
   this._x = this._x+this.speed*Math.cos(angle);
   this._y = this._y+this.speed*Math.sin(angle);
   this._rotation = angle/Math.PI*180-90
  };
 }
};

测试结果!good luck to you!