Posted: Fri May 02, 2008 11:31 pm Post subject: Sprite sheet help needed
For the various games I'm currently trying to code I'm in need of a whole bunch of sprites. Finding the sprites is not the problem, but the idea of making a hundred separate pictures seems tedious and rather inefficient. Essentially what I'm looking to do is this: (for a sprite sheet with 100 sprites each 25 by 25 pixels)
code:
Image spriteSheet = new Image("SpriteSheet.gif");
Image[]sprite = new Image [100];
int z=0;
final int PICX=25;
final int PICY=25;
for (int x=0;x<10;x++)
for (int y=0;y<10;y++)
{
sprite[z]= new Image (spriteSheet,x*25,y*25,PICX,PICY); //The idea here being that I want to create a new picture off the spritesheet of size PICX by PICY starting at coordinates x*25,y*25
z++;
}
I've been looking but can't for the life of me find the java code (for an applet btw) that will allow me to do this. Any suggestions?