public Path getPath ( Sprite sprite , int x , int y , boolean loose ) { // sanity check if ( sprite == null ) { throw new IllegalArgumentException ( "Can't get path for null sprite [x=" + x + ", y=" + y + "." ) ; } // get the destination tile coordinates Point src = MisoUtil . screenToTile ( _metrics , sprite . getX ( ) , sprite . getY ( ) , new Point ( ) ) ; Point dest = MisoUtil . screenToTile ( _metrics , x , y , new Point ( ) ) ; // compute our longest path from the screen size int longestPath = 3 * ( getWidth ( ) / _metrics . tilewid ) ; // get a reasonable tile path through the scene long start = System . currentTimeMillis ( ) ; List < Point > points = AStarPathUtil . getPath ( this , sprite , longestPath , src . x , src . y , dest . x , dest . y , loose ) ; long duration = System . currentTimeMillis ( ) - start ; // sanity check the number of nodes searched so that we can keep an eye out for bogosity if ( duration > 500L ) { int considered = AStarPathUtil . getConsidered ( ) ; log . warning ( "Considered " + considered + " nodes for path from " + StringUtil . toString ( src ) + " to " + StringUtil . toString ( dest ) + " [duration=" + duration + "]." ) ; } // construct a path object to guide the sprite on its merry way return ( points == null ) ? null : new TilePath ( _metrics , sprite , points , x , y ) ; }
Computes a path for the specified sprite to the specified tile coordinates .