So I have this code and I’m trying to make the text fade in and out. I could make in fade in but I couldn’t make it fade out. Could anyone help me?
int t=10; //transparency
besides that a code is better readable if it is formatted,
you need to work on the
and best is you use a println("");
to check how any logic you code turn out.
or other way could be to take out the text("",x,y);
after the if () fill…
and make it a
text("help, t: "+t,10,100);
sorry! I wasn’t sure how to keep the format since I’ve just made an account but maybe it’s easier to understand now. I’m not sure how to fix my ‘if’ statement because to my understanding, the value of t would keep adding until it reaches 255, and will start to decrease once it hits over 255. I’m not sure if there’s anything wrong with that logic, so maybe you could help me check over my line of thinking?
Why the text couldnt fade out is caused by if else logic.
When t reached 256 (t > 255), it will back to 255 and then it will be back again to 256, because it does qualified to enter the
else part where the t should be greater than 255. When t is 255 it enters
if part rather than
So after the text faded in, it will be back and forth between 255 and 256.
@kll has posted or
t to see what happen
Thank you for clarifying that! I’ll try to fix my ‘if’ and check the value of t