Hi, i have written this little program to cut a spritesheet for me, but it doesn’t work with transparency. Anybody know a fix?
PImage sheet = loadImage("dirtTiles.png");
PImage[] tiles = new PImage[25];
int s = 16;
background(200, 100, 100);
String tileName = "dirt";
size(80, 80);
loadPixels();
int index = 0;
for(int x = 0; x < sheet.width; x += s){
for(int y = 0; y < sheet.height; y += s){
//tile
PImage cTile = createImage(s, s, RGB);
for(int xt = 0; xt < s; xt++){
for(int yt = 0; yt < s; yt++){
int sheetindex = x + xt + (y + yt) * sheet.width;
int tileindex = xt + yt * s;
cTile.pixels[tileindex] = sheet.pixels[sheetindex];
}
}
cTile.updatePixels();
tiles[index] = cTile;
index++;
}
}
for (int i = 0; i < tiles.length; i++) {
tiles[i].save(tileName + str(i));
}