As the crow flies
May 28th, 2007
The ultimate goal for this project is some sort of tile-based game. To that end I’m working to get a solid pathfinding algorithm in place before anything else. In this version of the isometric grid I have a departure point and a destination represented by a cube and an obelisk respectively. I’ve also made the grid tiles mutable, ie. clicking on a tile turns it grey and the terrain becomes untraversable.
The two endpoints are draggable and have code to ‘snap’ them onto whatever tile they stop on. Currently the path is a direct line from A to B and untraversable tiles are ignored. Here's the code: iso_grid_01.zip.
2 methods, 2 problems
May 27th, 2007
Alright…two takes on hitTest. AS3 has handily given us hitTestObject – true if bounding-boxes overlap – and hitTestPoint, which checks for overlap between one coordinate and the object. It will also take a third parameter to check against either the bounding-box area of the object, or the actual filled shape therein.
First off, a test using hitTestObject. Every tile who’s bounding box intersects my little draggable circle will highlight. This is the same issue I had before with AS2 hitTest.
Now, a somewhat better version which uses the center point of the circle. This one gives much better results but still not quite perfect.
The jump to AS3
May 26th, 2007
From here on out I’m going to be working in ActionScript 3 and hopefully posting a lot more of my code tests.
Back on track
May 26th, 2007
After a little digging (and two months of neglect), I’ve got a solution to my hitTest woes. It turns out that hitTest is checking for overlap between the bounding-box of the ball and the bounding-boxes of…pretty much anything else on stage. Since my entire grid is skewed from the traditional cartesian, each tile gets a hitspace exactly twice the area of the graphic inside it. In the image below, the blue box shows anywhere that would give a positive hitTest result for the upper-left tile.

