mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-02-11 03:17:13 +07:00
Fixed issue with camera toScreen coordinates applying pixel offset at incorrect time
Fixed issue with camera toScreen coordinates applying pixel offset at incorrect time Added debug render of iso boundary rect
This commit is contained in:
parent
43c9f14799
commit
0c4c4a5fb1
@ -29,7 +29,7 @@ public class IsometricCamera extends OrthographicCamera {
|
||||
public void translate(float x, float y) {
|
||||
position.add(x, y);
|
||||
toScreen(position.x, position.y, tmp);
|
||||
super.position.set(tmp, 0).add(pixOffset.x, pixOffset.y, 0);
|
||||
super.position.set(tmp, 0);
|
||||
}
|
||||
|
||||
public void set(Vector2 vec) {
|
||||
@ -39,7 +39,7 @@ public class IsometricCamera extends OrthographicCamera {
|
||||
public void set(float x, float y) {
|
||||
position.set(x, y);
|
||||
toScreen(position.x, position.y, tmp);
|
||||
super.position.set(tmp, 0).add(pixOffset.x, pixOffset.y, 0);
|
||||
super.position.set(tmp, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,7 +53,8 @@ public class IsometricCamera extends OrthographicCamera {
|
||||
* Converts tile coords to screen coords.
|
||||
*/
|
||||
public Vector2 toScreen(float x, float y, Vector2 dst) {
|
||||
return EngineUtils.worldToScreenCoords(x, y, dst);
|
||||
EngineUtils.worldToScreenCoords(x, y, dst);
|
||||
return dst.add(pixOffset);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -109,4 +110,15 @@ public class IsometricCamera extends OrthographicCamera {
|
||||
dst.y = y < 0 ? MathUtils.round(y) : MathUtils.roundPositive(y);
|
||||
return dst;
|
||||
}
|
||||
|
||||
public Vector2 screenToWorld(float x, float y, Vector2 dst) {
|
||||
dst.set(x, y);
|
||||
unproject(dst);
|
||||
return toWorld(dst);
|
||||
}
|
||||
|
||||
public Vector2 screenToTile(float x, float y, Vector2 dst) {
|
||||
screenToWorld(x, y, dst);
|
||||
return toTile(dst);
|
||||
}
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ public class CameraTool extends ApplicationAdapter {
|
||||
|
||||
shapes.set(ShapeRenderer.ShapeType.Filled);
|
||||
shapes.setColor(Color.SALMON);
|
||||
DebugUtils.drawDiamond(shapes, vec2.x, vec2.y - Tile.SUBTILE_HEIGHT50, Tile.SUBTILE_WIDTH, Tile.SUBTILE_HEIGHT);
|
||||
DebugUtils.drawDiamond(shapes, vec2.x, vec2.y, Tile.SUBTILE_WIDTH, Tile.SUBTILE_HEIGHT);
|
||||
|
||||
shapes.set(ShapeRenderer.ShapeType.Filled);
|
||||
shapes.setColor(Color.GREEN);
|
||||
@ -196,9 +196,19 @@ public class CameraTool extends ApplicationAdapter {
|
||||
iso.toScreen(vec2);
|
||||
|
||||
shapes.setColor(Color.WHITE);
|
||||
DebugUtils.drawDiamond(shapes, vec2.x, vec2.y - Tile.SUBTILE_HEIGHT50, Tile.SUBTILE_WIDTH, Tile.SUBTILE_HEIGHT);
|
||||
DebugUtils.drawDiamond(shapes, vec2.x, vec2.y, Tile.SUBTILE_WIDTH, Tile.SUBTILE_HEIGHT);
|
||||
} shapes.end();
|
||||
|
||||
shapes.begin(ShapeRenderer.ShapeType.Line); {
|
||||
tmp.set(iso.position);
|
||||
iso.toScreen(tmp);
|
||||
shapes.rect(
|
||||
tmp.x - iso.viewportWidth / 2 - 1,
|
||||
tmp.y - iso.viewportHeight / 2 - 1,
|
||||
iso.viewportWidth + 2,
|
||||
iso.viewportHeight + 2
|
||||
);
|
||||
} shapes.end();
|
||||
|
||||
float width;
|
||||
batch.begin();
|
||||
|
Loading…
Reference in New Issue
Block a user