0
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)

4

1 回答 1

0

我通过将图像放在正确的文件夹中来解决我自己的问题,替换旧的精灵图像表。

于 2012-10-08T18:34:27.183 回答