|
Flash教程:走迷宫游戏的制作基础实例(2) 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!
|