0

我目前正在尝试编写一个简单的平台游戏。我想将图形放大 2/4 倍,这样我就可以从游戏中获得老式的外观和感觉。但是,当我在 Graphics2D 实例上调用 scale 时,什么也没有发生。

@Override
public void paint(Graphics g) {

    BufferStrategy bf = this.getBufferStrategy();

    Graphics2D bfg = (Graphics2D) bf.getDrawGraphics();

    mLevel.draw(bfg, this);

    for (GameEntity entity : mGameEntities) {
        entity.draw(bfg, this);
    }

    bfg.scale(2.0, 2.0);

    bf.show();

}

绘制调用基本上只是最终调用 g.drawImage(..)。其他所有内容都正确绘制,所以我不明白为什么它没有将所有内容放大 2 倍。

4

1 回答 1

0

@MadProgrammer 是正确的 - 在进行任何绘制调用之前必须缩放 Graphics2D 实例。

@Override
public void paint(Graphics g) {

    BufferStrategy bf = this.getBufferStrategy();

    Graphics2D bfg = (Graphics2D) bf.getDrawGraphics();

    bfg.scale(2.0, 2.0);

    mLevel.draw(bfg, this);

    for (GameEntity entity : mGameEntities) {
        entity.step();
        entity.draw(bfg, this);
    }



    bf.show();

}
于 2013-04-15T18:00:01.747 回答