@Override protected void drawSprite(CoreGraphics g) { int w = width.getAsInt(); int h = height.getAsInt(); int xMax = w - 1; int yMax = h - 1; // Fill with base color g.setColor(color.get()); g.fillRect(0, 0, w, h); if (color.get() != EMPTY) { toString(); } if (!isFixed()) { // Draw brighter lines g.setColor(Colors.brighter(color.get())); for (int i = 0; i < squareSize / 10; i++) { g.drawLine(i, i, xMax - i, i); g.drawLine(i, i, i, yMax - i); } // Draw darker lines g.setColor(Colors.darker(color.get())); for (int i = 0; i < squareSize / 10; i++) { g.drawLine(xMax - i, i, xMax - i, yMax - i); g.drawLine(i, yMax - i, xMax - i, yMax - i); } } }
@Override public void update(int elapsedTime) { super.update(elapsedTime); if (gameOver && !color.isAnimating()) { color.animateTo(0xFF000000 | rnd.nextInt(), 900 + rnd.nextInt(300), Easing.REGULAR_IN_OUT); } int old = color.get(); color.update(elapsedTime); if (color.get() != old) { setDirty(true); } }
public int getColor() { return color.get(); }
private void copy(SquareSprite other) { setFixed(other.isFixed()); setColor(other.getColor()); color.setBehavior(other.color.getBehavior()); }