Browse Source

refactoring:

main
Justin Senn 2 years ago
parent
commit
f66be06f00
  1. 4
      src/main/java/Snake/TextView.java

4
src/main/java/Snake/TextView.java

@ -50,10 +50,10 @@ public class TextView implements Drawable
{ {
FontMetrics fontMetrics = g.getFontMetrics(); FontMetrics fontMetrics = g.getFontMetrics();
int x = position.x; int x = position.x;
int y = position.y + fontMetrics.getHeight();
int y = position.y + fontMetrics.getHeight() / 2;
if (anchor == AnchorType.Center) if (anchor == AnchorType.Center)
x -= fontMetrics.stringWidth(text);
x -= fontMetrics.stringWidth(text) / 2;
else if (anchor == AnchorType.Right) else if (anchor == AnchorType.Right)
x -= fontMetrics.stringWidth(text); x -= fontMetrics.stringWidth(text);

Loading…
Cancel
Save