What codes do I use to make my car invincible for 5 seconds if my car grabbed another object in other words it's a powerup. Thank you in advance for your help :)
private int t_invincible = 0;
//in act method
if (t_invincible > 0) t_invincible--;
//getting the powerup
if (isTouching(PowerUp.class))
{
removeTouching(PowerUp.class);
t_invincible = 280;
}
//when checking for a crash
if (t_invincible==0 && isTouching(/*whatever*/.class))
{
//action when crash is detected
}