【发布时间】:2014-07-03 10:31:35
【问题描述】:
您好,我有以下两个等距图块:
普通瓷砖(水):
岩砖:
我需要在我的游戏板中添加一些像岩石瓷砖这样的瓷砖,但问题是,像这块石头这样的一些瓷砖需要更大的高度。
目前,岩石瓷砖的高度增加了 18 像素。 我尝试将岩石分成 3 块瓷砖,但它看起来很难看,因为你可以看到岩石上地砖的线条。
目前,板子是这样的:
(来源:gyazo.com)
如您所见,由于高度不同,瓷砖的位置会有所不同。
我的图形代码层是分层设计的,其中有一个叫Board的层,Board层包含一个叫Nature的层,负责岩石、花朵等。
我的棋盘图:
@Override
public void render(Graphics g) {
g.translate(this.translate.getX(), this.translate.getY());
for (int i = 0; i < tiles[0].length; i++) {
for (int j = 0; j < tiles[1].length; j++) {
int x = (j * sprite.getWidth() / 2) - (i * sprite.getWidth() / 2);
int y = (j * sprite.getHeight() / 2) + (i * sprite.getHeight() / 2);
this.tiles[i][j].render(g, x, y);
}
}
// rendering rocks and so on..
this.nature.render(g);
}
这就是我渲染自然层的方式:
@Override
public void render(Graphics g) {
for (int i = 0; i < this.tiles[0].length; i++){
for (int j = 0; j < this.tiles[1].length; j++){
if (this.tiles[i][j] == null)
continue;
int width = this.tiles[i][j].getWidth();
int height = this.tiles[i][j].getHeight();
int x = (j * width / 2) - (i * width / 2);
int y = (j * height / 2) + (i * height / 2);
g.drawImage(this.tiles[i][j], x, y);
}
}
}
我尝试将高度减去 18,但仍然没有运气,它仍然很乱。 是否有任何正确方法可以绘制大于实际尺寸的图块?
【问题讨论】: