Exemplo n.º 1
0
  public void update() {

    if (!isValid()) {
      recalculateBoundsSize(text);
      recalculateBounds();
      validate();
    }

    colorTransition.update(GlobalTime.getDelta());

    libgdxPointer.update();

    pressed = false;
    released = false;

    boolean inside = MathUtils2.inside(bounds, libgdxPointer.getPosition());

    if (wasInside && !inside) colorTransition.start(0.25f, notOverColor);

    if (!wasInside && inside) colorTransition.start(0.25f, overColor);

    wasInside = inside;

    if (libgdxPointer.wasPressed)
      pressed = MathUtils2.inside(bounds, libgdxPointer.getPressedPosition());

    if (libgdxPointer.wasReleased)
      released = MathUtils2.inside(bounds, libgdxPointer.getReleasedPosition());

    if (pressed) buttonHandler.onPressed(this);

    if (released) buttonHandler.onReleased(this);

    // NOTE: for now the button could be released while it was never pressed before

  }