I have a very unique question regarding to my project
I have made a Grid including 25x15 cells using 3 classes:
First class named Tile.as and make cells for me:
public class Tile extends Sprite
static const TILE_SIZE:int = 30;
public function Tile()
var tile:Shape=new Shape();
tile.graphics.drawRect(TILE_SIZE / 2, TILE_SIZE / 2, TILE_SIZE, TILE_SIZE);
The next class named Grid.as to integrate all Tile together:
public class Grid extends Sprite
static const GRID_SIZE:int = 25;
private var tileList:Vector.<Tile>;
public function Grid()
tileList = new Vector.<Tile>;
for (var v:int = 0; v < GRID_SIZE; v++)
for (var z:int = 0; z < GRID_SIZE-15; z++)
var tile:Tile = new Tile();
tile.x = v*Tile.TILE_SIZE;
tile.y = z*Tile.TILE_SIZE;
tile = null;
And then I showed Grid in my Main.as class and show it in the out put:
public class Main extends Sprite
private var grid:Grid;
public function Main()
//show the grid
grid = new Grid();
grid.x = 10;
grid.y = 10;
This is what I can see now:
My question is that i want to add two objects in this grid. For example:
object A will be located in one cell (Tile)
object B will be located in another cell (Tile)
and then I want to connect these 2 objects together by highlighting the dimensions of the cells!
this is an example of what I need to have:
Please ask me, if there is more explanation need to added!
And if I am going through the wrong way, please make me correct!
Thanks in advance!
i'm not sure if this question was about path finding!
but according @NealDavis comment:
i post a library for this possibility. however its a grid based path finding and also drawing, even with a fully clear grid.
from dauntless :
According to WikiPedia, A* (pronounced A Star) is
a best-first, graph search algorithm that finds the least-cost path from a given initial node to one goal node (out of one or more possible goals).
Here is a Live Demo
References to this library