Hi Guys…
Im having a bit of difficult to come with an idea about this :
A) The image keeps fading out… in 4 seconds, it should be completely black.
B)The image then fades in, in 4 seconds, it should be completely opaque again.
Problem is… DeltaTime…
How do i calculate it properly?
This works perfectly for 4 seconds at 60 fps,
But what if a variation happens? If it was fixed, i would know how-to, but it can goes to 1/30 then 1/45 then 1/60… etc… thats what i dont get it…
Any math tip or code tip, is appreciated. I know i was supposed to know this, but im kinda confused…
Thanks a lot in advance guys and girls?
if (!fadeSparkle) {
alpha = alpha - (0.25f) / (1f/delta);
System.out.println("Fade Out! Alpha = " + alpha);
player.getCurrent_Level().batch.setColor(1, 1, 1, alpha);
player.getCurrent_Level().renderer.getSpriteBatch().setColor(1, 1, 1, alpha);
if (alpha <= 0) {
fadeSparkle = true;
}
} else {
alpha = alpha + (0.25f) / (1f/delta);
System.out.println("Fade In! Alpha = " + alpha);
player.getCurrent_Level().batch.setColor(1, 1, 1, alpha);
player.getCurrent_Level().renderer.getSpriteBatch().setColor(1, 1, 1, alpha);
if (alpha >= 1) {
sparkled = true;
}
}