August 2010
Intermediate to advanced
412 pages
8h 59m
English
We modify the World class to listen on mouse click event. When the mouse clicks the world, we get the isometric tile position from the mouse screen coordinate. The map is the reference to the IsometricMapData class which contains the A* pathfinding class. We set up the starting and ending points for the pathfinding class to find a path solution. Then we pass the path to the WalkingAvatar class to follow. At last we need to update the position in the room variables.
private function onMapClicked(e:MouseEvent):void { var newIsoPosition:Point = map.s2i(stage.mouseX,stage.mouseY); if (!map.isWalkable(newIsoPosition.x,newIsoPosition.y)){ trace("can't walk to there"); return; } /* find the path by A* pathfinding class */ map.astarMap.setEndPoints(myAvatar.isoPosition.x,_myAvatar. ...Read now
Unlock full access