1
\$\begingroup\$

enter image description here

As you see, the "Retry" button and the "Invite Friends" button are both animated, smoothly and cleanly.

If I were to do this in Libgdx, would I have to use the Animation class and provide multiple texture regions of the buttons to create this animation effect? Or are in built methods included to help simulate this effect?

I've seen examples of people claiming you must use OpenGl ES methods directly. Is that true? Are there extensions to help create this effect?

\$\endgroup\$
1
  • \$\begingroup\$ I think that's just a textured quad getting stretched \$\endgroup\$
    – Bálint
    Jan 22, 2018 at 19:53

1 Answer 1

0
\$\begingroup\$

If you're using Actors you can use Actions to stretch the image. The action you're looking for is ScaleByAction which can be accessed using the Actions.scaleBy method.

So your code might look something like this:

Stage stage = ... // Create stage
Button button = ... // Create button

// Stretch button out, then in, then out, etc.
Action stretchSequence = Actions.sequence(Actions.sizeBy(10, 0, 1), Actions.sizeBy(-10, 0, -1));
// Repeat that sequence indefinitely
button.addAction(Actions.repeat(RepeatAction.FOREVER, stretchSequence));

stage.addActor(button);

// Then in your render() method
stage.act();
stage.draw();
\$\endgroup\$
3
  • \$\begingroup\$ This should work with other actors, like labels, right? Not only buttons? \$\endgroup\$
    – Erick Adam
    Jan 25, 2018 at 2:35
  • \$\begingroup\$ @ErickAdam Yes, everything that extends Actor can use this method. \$\endgroup\$
    – Charanor
    Jan 25, 2018 at 8:46
  • \$\begingroup\$ Would the above example work with an Actor object that uses a texture region? \$\endgroup\$
    – Erick Adam
    Jan 27, 2018 at 0:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .