public Image getSprite ( int x , int y ) { target . init ( ) ; initImpl ( ) ; if ( ( x < 0 ) || ( x >= subImages . length ) ) { throw new RuntimeException ( "SubImage out of sheet bounds: " + x + "," + y ) ; } if ( ( y < 0 ) || ( y >= subImages [ 0 ] . length ) ) { throw new RuntimeException ( "SubImage out of sheet bounds: " + x + "," + y ) ; } return target . getSubImage ( x * ( tw + spacing ) + margin , y * ( th + spacing ) + margin , tw , th ) ; }
Get a sprite at a particular cell on the sprite sheet