How can I make a LibGDX Actor object flicker over a set duration?
Many 2D platformers have the player character 'flicker' after taking damage to indicate temporary invincibility, (ie: invincibility frames). For an example, see the below gif from Shovel Knight.
It's fairly simple to make an object fade in or out over time using LibGDX's Actions library.
Actor player = new Actor();
// fade out in 0.25 seconds
player.addAction(Actions.fadeOut(0.25));
But searching through the documentation, I couldn't find any method for Actions.flicker()
. How can I implement sprite flickering in LibGDX?