- 浏览: 601650 次
- 性别:
- 来自: 广州
-
文章分类
最新评论
-
wzh051527:
我是大四实习生一个,自我感觉技术能力在第三年。。唯一不明白,为 ...
十年技术,不要再迷茫 -
room_bb:
.hrl文件怎么加入到编译规则里面?比如:pp.hrl文件-d ...
Erlang中用的makefile的一点解释 -
吉米家:
感觉帆软报表的flash打印就很不错哇,特别好用
JSP 实现报表打印 -
雪碧爱芬达:
苦逼程序员的辛酸反省与总结 -
mlyjxx:
...
十年技术,不要再迷茫
import flash.geom.Point; import flash.display.Sprite; import com.qrpg.Algorithm.PathFinding; var t:int; var field:Sprite = new Sprite();//地图图层 addChild(field); var linePath:Sprite = new Sprite();//网格图层 addChild(linePath); var allNode:Array = []; //节点数据(小格子) var map:Array = []; //网格 //随机制定网格,35行60列 for (var mapy:int=0; mapy<35; mapy++) { if (map[mapy]==undefined) { map[mapy] = []; } //随机生成网格 for (var mapx:int=0; mapx<60; mapx++) { map[mapy][mapx] = Math.random()>.25 ? 0 : 1 ; } } //var map:Array=[[0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0],[0,0,0,1,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,0,1,0,0,0,0,0,0,0,1,1,0,0],[0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,1,0,0,1,0,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,1,1],[0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,0,1,1,1,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,1,0,0,1],[0,0,0,0,0,0,0,0,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,0,1,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,0],[0,0,0,0,1,0,0,0,0,1,0,0,1,1,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,1,0,1,0,0,0,0,1,0,0,1,0,1,0,1,0,0,0,0,1,0,0,0],[1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,0,0,0,0,0,0,0,1],[0,0,0,0,1,0,0,0,0,0,0,0,1,1,0,0,1,0,0,0,0,1,0,0,1,0,0,0,0,0,1,1,1,1,0,0,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,1,0,0,0,0,0,0,0,0],[1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0,0,1,1,0,0,0,0,1,0,0,1,0,1,0,0,0,1,1,1,0,1,0,0,1,1,0],[0,0,0,1,0,0,1,0,0,1,1,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,0,0,1,1,0,0,1,0,0,1,0,0,0,0,0,1,0,0]]; var w:int = map[0].length; //列长度 var h:int = map.length; //行长度 var path:Array; //路径1 var path2:Array; //路径2 var startpoint:Point = new Point(); //程序启动时的始点 var findPath:PathFinding = new PathFinding(map); //创建包含网格地图的数组(元素是对象) //在界面上画出节点 for (var py:int=0; py<h; py++) { if (allNode[py]==undefined) { allNode[py] = []; } for (var px:int=0; px<w; px++) { allNode[py].push(field.addChildAt(new node(), field.numChildren)); //把新建的节点加入到每一行中,列不断增加 allNode[py][px].p = new Point(px, py); //用数据索引新建一个当前点的代表坐标点 allNode[py][px].x=px*10; //设定此节点的坐标 allNode[py][px].y=py*10; //allNode[py][px].gotoAndStop(map[py][px]==0?1:2); //原理和下面相同 if (map[py][px]==0) { //判断是否不是障碍 allNode[py][px].stop(); //如果不是障碍,则停止增加节点,增加事件监听 allNode[py][px].addEventListener(MouseEvent.CLICK, findHandler); } else { allNode[py][px].gotoAndStop(2);//障碍进入第二帧 } } } field.x = 30; //设定图层开始显示的坐标 field.y = 10; linePath.x = field.x+5; //第一个节点的中心点 linePath.y = field.y+5; function findHandler(e:MouseEvent):void { t = getTimer(); //取得当前的毫秒数 for (var y:int=0; y<h; y++) { for (var x:int=0; x<w; x++) { if (allNode[y][x].currentFrame>2) { //不允许 每个节点的帧数大于2 allNode[y][x].gotoAndStop(1); } } } //指定默认的起始点和当前点击的节点的对应P点(*10可得到准确左上角路径),返回一个数组 path = findPath.path4(startpoint, e.currentTarget.p); var len:int = path.length; //把路径的格子设为绿色 for (var i:int=0; i<len; i++) { allNode[path[i].y][path[i].x].gotoAndStop(3); } if (len==0) { trace_mc.text = "无法到达!"; //如果返回路径的长度为0,则表示路径为0 ,不能到达 } else { //path2 = findPath.optimizePath(); path2=path; //画出路径上的白色线条 var len2:int = path2.length; linePath.graphics.clear(); linePath.graphics.lineStyle(2,0xffffff,1); for (var j:int=0; j<len2; j++) { if (j==0) { linePath.graphics.moveTo(path2[j].x*10, path2[j].y*10); } else { linePath.graphics.lineTo(path2[j].x*10, path2[j].y*10); } } startpoint = e.currentTarget.p; trace_mc.text = "经过格子"+len+"个,"; } //计算寻路用了多少时间 trace_mc.appendText("所用时间:"+(getTimer()-t)+"毫秒。"); } reset_mc.addEventListener(MouseEvent.CLICK, resetHandler); function resetHandler(e:MouseEvent):void { } // package com.qrpg.Algorithm{ import flash.geom.Point; import com.qrpg.Algorithm.Diagonal; public class PathFinding { private var _map:Array;//网格地图(元素是对象) private var _w:int;//网格地图的宽 private var _h:int;//网格地图的高 private var _open:Array;//开放列表 private var _starPoint:Object; private var _endPoint:Object; public var path:Array = [];//计算出的路径 public function PathFinding(map:Array) { _map = []; //接收网格地图 _w = map[0].length; _h = map.length; for (var y:int=0; y<_h; y++) { if (_map[y]==undefined) { _map[y] = []; } //把每个节点创建成对象,再保存到数组里面 for (var x:int=0; x<_w; x++) { _map[y][x] = {x:x, y:y, value:map[y][x], block:false, open:false, value_g:0, value_h:0, value_f:0, nodeparent:null}; } } } //四方向寻路 public function path4(star:Point, end:Point):Array { path = []; _starPoint = _map[star.y][star.x]; //取得起始点和结束点 _endPoint = _map[end.y][end.x]; var __getEnd:Boolean = false; //判断是否到了结束点 initBlock(); //寻路前的初始化 var __thisNode:Object = _starPoint; //得到开始点 //循环判断是否到了结束点,直到以最优路径方式找到结束点为止 while (!__getEnd) { __thisNode.block = true; //把起始点设为障碍 var __checkList:Array = []; //检查数组 //把当前的周围的四个节点加入检查数组中,等待检查 if (__thisNode.y>0) { __checkList.push(_map[(__thisNode.y-1)][__thisNode.x]); } if (__thisNode.x>0) { __checkList.push(_map[__thisNode.y][(__thisNode.x-1)]); } if (__thisNode.x<_w-1) { __checkList.push(_map[__thisNode.y][(__thisNode.x+1)]); } if (__thisNode.y<_h-1) { __checkList.push(_map[(__thisNode.y+1)][__thisNode.x]); } //开始检测当前节点周围 var __len:int = __checkList.length; for (var i:int = 0; i<__len; i++) { //取得周围的每一个节点 var __neighboringNode:Object = __checkList[i]; //判断是否是目的地 if (__neighboringNode == _endPoint) { __neighboringNode.nodeparent = __thisNode; //设定此周围节点的父节点,即连接此的节点的上一节点 __getEnd = true; break; } //是否可通行 if (__neighboringNode.value == 0) { count(__neighboringNode, __thisNode);//计算该节点,传送周围节点和当前中间点过去 } } if (!__getEnd) { //如果未找到目的地 if (_open.length>0) { //开发列表不为空,找出F值最小的做为下一个循环的当前节点 __thisNode = _open.splice(getMin(),1)[0]; } else { //开发列表为空,寻路失败 return []; } } } drawPath(); return path; } //优化路径 public function optimizePath():Array { var __len:int = path.length; var __path:Array = []; var diagonal:Array = []; //斜线数组 var __dLen:int; var __cross:Boolean = true; var __currentNode:Point = path[0]; //起点 __path.push(path[0]); //加入到优化后的数组 for (var i:int=1; i<__len; i++) { diagonal = Diagonal.each(__currentNode, path[i]); __dLen = diagonal.length; //返回一个数组 __cross = true; for (var j:int=0; j<__dLen; j++) { if (_map[diagonal[j].y][diagonal[j].x].value == 1) { __cross = false; break; } } if (!__cross) { if (i>1) { __currentNode = path[(i-1)]; __path.push(path[(i-1)]); } } } __path.push(path[(__len-1)]); return __path; } //寻路前的初始化,设置每个节点的节点属性 private function initBlock():void { for (var y:int=0; y<_h; y++) { for (var x:int=0; x<_w; x++) { _map[y][x].open = false; //可以通过 _map[y][x].block = false; //障碍 _map[y][x].value_g = 0; _map[y][x].value_h = 0; _map[y][x].value_f = 0; _map[y][x].nodeparent = null; //寻路过程中的上一点 } } _open = []; } //计算每个节点,接收周围节点和周围节点的中间点 private function count(neighboringNode:Object, centerNode:Object):void { //是否在关闭列表里 if (!neighboringNode.block) { //不在关闭列表里才开始判断 var __g:Number= centerNode.value_g+10; //判断此点是否是障碍 if (neighboringNode.open) { //如果该节点已经在开放列表里 if (neighboringNode.value_g>=__g) { //如果新G值小于或者等于旧值,则表明该路更优,更新其值 neighboringNode.value_g = __g; ghf(neighboringNode); //计算GHF的值 neighboringNode.nodeparent = centerNode; //把周围节点的上一节点设为中心节点 } } else { //如果该节点未在开放列表里 //添加至列表 addToOpen(neighboringNode); //计算GHF值 neighboringNode.value_g = __g; ghf(neighboringNode); neighboringNode.nodeparent = centerNode; } } } //画路径 private function drawPath():void { var __pathNode:Object = _endPoint; //倒过来得到路径 while (__pathNode != _starPoint) { path.unshift(new Point(__pathNode.x, __pathNode.y)); __pathNode = __pathNode.nodeparent; } path.unshift(new Point(__pathNode.x, __pathNode.y)); } //加入开放列表 private function addToOpen(newNode:Object):void { _open.push(newNode); newNode.open = true; } //计算周围节点的ghf各值 private function ghf(node:Object):void { var __dx:Number = Math.abs(node.x-_endPoint.x); var __dy:Number = Math.abs(node.y-_endPoint.y); node.value_h = 10*(__dx+__dy); //计算周围节点到结束点的X,Y的相差距离(X相差距离+Y相差距离) node.value_f = node.value_g+node.value_h; //计算最优路径+XY的相差距离 (总距离) } //得到开放列表里拥有最小F值的节点在列表里的位置 private function getMin():int { var __len:int = _open.length; var __f:Number = 100000; var __i:int = 0; for (var i:int = 0; i<__len; i++) { if (__f>_open[i].value_f) { __f = _open[i].value_f; __i = i; } } return __i; } } }
发表评论
-
as3 Loader 加载资源后内存泄露无法释放的问题。
2014-06-21 10:30 700as3 Loader 加载资源后内存泄露无法释放的问题。 ... -
as3判断flash player版本的函数
2014-06-10 20:35 859//判断当前版本是否高于9.0.115.0为例子. pr ... -
CSS 中文字体的英文名称 (simhei, simsun) 宋体 微软雅黑
2014-04-03 15:25 1065华文细黑:STHeiti Light [STXihei]华文 ... -
as3.0的垃圾回收机制
2013-09-07 14:02 1557还是同样的博客,还是同样的作者(Daniel Sidhio ... -
AIR程序多开
2013-09-07 13:55 1022AIR应用通常不能像QQ那样能进行多开操作。为了让一个用AI ... -
starling性能优化总结
2013-07-22 14:06 1491在项目开发的过程中总结了一下starling的性能优化方案: ... -
AS3 Socket从零开始
2013-07-22 12:54 1123大家如果想学AS3 Socket直接在百度里搜一下,会找到很 ... -
绕开AS3安全沙箱 跨域加载SWF
2013-07-11 12:53 930AS3的安全沙箱的确是 ... -
解决AS3在ie中初始化时stageWidth和stageHeight为0
2013-06-14 09:23 1046先看下面的一段脚本,这是比较经典的初始化脚本: pac ... -
动态获取swc中的类
2013-05-25 10:32 998想通过代码生成,来获取swc中的类,并且可以作为普通类正常使 ... -
AS3 中字符串的format功能实现
2013-05-25 10:19 856使用C#的朋友都知道,string.Format();还是挺 ... -
总结调用Flash的几种方法
2013-05-02 16:18 1691一、Adobe 提供的方法 <object wi ... -
Flash3D错误集锦
2013-05-02 14:03 967VerifyError: Error #1014: 无法找到 ... -
使用scale拉伸之后的坐标问题
2013-04-12 09:38 1315最近发现论坛多了很多 ... -
30个实用的网页设计工具
2013-03-20 09:58 856作为一位网页设计师或开发者,你一直需要搜寻获取强大的网页设计 ... -
如何成为强大的程序员?
2013-03-11 11:27 749Aaron Stannard是新创公 ... -
漫谈重构
2013-03-11 11:09 905因为工作内容的原因, ... -
AS3使用谷歌API生成二维码
2012-12-10 16:24 1382二维码在新闻杂志,网站,网络广告,电视广告等地方随处可见 ... -
OOP的聚合原则
2012-12-10 16:21 947什么是聚合? 聚合可以很好地表达对象是什么和做 ... -
压缩速率追踪
2012-11-02 14:16 1495Flash Player 11.3添加了一个压缩和解压B ...
相关推荐
在Flash AS3环境中,寻路算法可以帮助角色或对象在虚拟世界中找到从起点到终点的最短路径。本篇文章将深入探讨"FLASH AS3 寻路算法"的相关知识点。 首先,我们要理解AS3(ActionScript 3)是Adobe Flash平台上的一...
通过深入理解这个AS3寻路算法的实现,开发者可以学习到如何在ActionScript 3环境中进行路径规划,这对于开发2D游戏、模拟或其他需要智能导航的项目是非常有价值的。同时,掌握寻路算法的基本原理和技巧,也可以为...
在AS3.0的单个文档类中实现A*寻路算法,你需要将以上步骤封装为类方法,可能包括`initGrid`(初始化网格)、`calculatePath`(计算路径)、`findNeighbours`(查找相邻节点)等。源码可能还会包含示例数据和用于测试...
寻路算法是一种在图形网络(如游戏地图)中找到从起点到终点最短或最优路径的方法。在RPG游戏中,这通常涉及到游戏内的角色自动寻找到达目标地点的最短或最佳路线。 最常用的寻路算法是A*(A-star)算法,它结合了...
以下是关于AS3 A星寻路算法的详细解释: 1. **基本概念**: - **节点(Nodes)**:在A星算法中,地图被抽象为一个由节点组成的网格。每个节点代表地图上的一个位置。 - **启发式函数(Heuristic Function)**:...
《ActionScript RPG 寻路算法游戏源码解析》 在游戏开发中,寻路算法是一项至关重要的技术,它决定了游戏角色如何在游戏世界中智能地移动。本篇文章将深入探讨一个基于ActionScript的RPG游戏源码,特别是其中采用的...
这里我们关注的是基于ACTIONSCRIPT 3 (AS3)实现的A*(A-Star)寻路算法。A*算法是一种启发式搜索算法,它结合了Dijkstra算法的全局最优性和BFS(广度优先搜索)的高效性,被广泛用于游戏中的智能体寻路问题。 A*...
这篇关于“AS3简单的寻路程序”的介绍将深入探讨如何在ActionScript 3 (AS3)中实现一个基本的寻路算法,该算法适用于二维网格地图,并能够处理不可通行和可通行的格子。 首先,我们需要理解AS3的基础。ActionScript...
本教程将深入探讨如何使用AS3实现经典寻路算法。 一、A*寻路算法 A*(A-star)算法是一种广泛应用的路径搜索算法,结合了Dijkstra算法的最短路径特性与启发式信息以提高效率。A*算法的核心在于计算每个节点的F值,...
总之,Flash AS3中的游戏寻路系统是一个涉及图形、动画、逻辑和算法的综合实践。通过深入理解A*算法并结合FLA源文件和扩展工具,开发者可以创建出流畅且高效的寻路体验,让游戏的角色能够在复杂的环境中自如移动。
在这个"as3 A*寻路源码"中,我们可以深入理解A*算法的工作原理及其在ActionScript 3(AS3)中的实现。 A*算法的核心思想是结合了Dijkstra算法的全局最优性和最佳优先搜索的效率。它通过一个评估函数f(n)来指导搜索...
标题“AS3 A星算法以及实例”表明我们将探讨的是使用ActionScript 3(AS3)语言实现的A星算法。AS3是Adobe Flash平台的主要编程语言,常用于创建交互式网页内容、游戏和动画。 描述中提到这是一个包含源文件和源...
A*(发音为 "A-star")寻路算法是一种在图形中寻找最短路径的高效算法,广泛应用于游戏开发、地图导航、网络路由等领域。它结合了Dijkstra算法的全局最优性和最佳优先搜索的效率,通过引入启发式函数来估计从起点到...
A*寻路算法是一种在图形或网格中...总之,A*寻路算法在AS3中提供了高效且灵活的路径规划解决方案,无论是四向还是八向寻路,都能根据启发式函数找到最优路径。理解并实现这些关键概念对于编写有效的寻路代码至关重要。
本文档基于《Advanced ActionScript 3.0 Animation》一书的第四章内容,旨在介绍寻路算法的基本概念及其在ActionScript 3.0中的实现方式。 #### 二、寻路算法概述 寻路算法的目标是在两点间寻找一条路径,尤其是在...
"com"目录可能包含了游戏的类库文件,这些AS3类文件封装了游戏的业务逻辑和算法实现,如A*寻路算法的具体代码。 综上所述,这个A*寻路的RPG游戏DEMO展示了如何利用先进的路径规划算法提升游戏体验,同时也体现了AS3...
AS3游戏实战(有源码)是针对Adobe Flash平台中ActionScript 3.0(AS3)编程语言的游戏开发教程,特别关注高级应用和自动寻路算法。在这款游戏中,开发者利用AS3的强大功能实现了一个高效的角色移动系统,使得人物能够...
3. **计算路径**:使用NavMesh的算法,如A*(A-Star)搜索算法,来找到起点到终点的最优路径。 4. **执行路径**:AI角色沿着计算出的路径进行移动,并根据需要实时更新路径,以应对动态环境的变化。 5. **优化和...