public BufferedImage[] sprites1()
{
BufferedImage[] sprites = new BufferedImage[6];
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 2; j++)
{
sprites[(i * 2) + j] = bigImg.getSubimage(j * 64, i * 64, 64, 64);
}
}
return sprites;
}
public BufferedImage[] sprites1Fliped()
{
BufferedImage[] sprites = new BufferedImage[6];
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 2; j++)
{
BufferedImage dimg = new BufferedImage(64, 64, sprites1()[i].getType());
Graphics2D g = dimg.createGraphics();
g.drawImage(sprites1()[i], 0, 0, 64, 64, 64, 0, 0, 64, null);
g.dispose();
sprites[i] = dimg;
}
}
return sprites;
}
ImageIcon img1a = new ImageIcon(images.sprites1()[5]);
ImageIcon img2a = new ImageIcon(images.sprites1()[2]);
ImageIcon img3a = new ImageIcon(images.sprites1()[3]);
ImageIcon img4a = new ImageIcon(images.sprites1()[0]);
ImageIcon img5a = new ImageIcon(images.sprites1()[1]);
ImageIcon img6a = new ImageIcon(images.sprites1()[4]);
setLayout(new GridBagLayout());
layout.add(l1); //l1 is a label with img1a, l2 img2a, ect.
layout.add(l2);
layout.add(l3);
layout.add(l4);
layout.add(l5);
layout.add(l6);
add(layout);
GridBagConstraints c = new GridBagConstraints();
c.weighty = 1.0;
c.weightx = 0;
c.anchor = GridBagConstraints.PAGE_END;
add(b1, c);
问题是面板应该显示精灵表中的橙色、黄色和蓝色龙。相反,它显示了一条翻转的橙色龙、一条橙色的龙和一条翻转的蓝色龙。
(这是 128x192)(每个都是 64x64)