We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I have 4 lines of text that I want to fade in and fade out when the mouse is clicked. I want each line to display consecutively(by clicking, the first line fades in. if i click again, it fades out, and then if i click again, the next line displays). How would I go about doing this? Would really appreciate any advice as Im a beginner
Answers
What do you have so far? What have you tried? Do you know how to diaplay a line of text? Do you know how to use variables? Do you know how to use the function mouseClicked()?
https://processing.org/reference/int.html https://processing.org/reference/text_.html https://processing.org/reference/mouseClicked_.html
Yes I know how how to display a line of text. I want the text to display over a sketch of mine and I'm just struggling how to format my code - whether to make a class and how to work that into my main code.
This is my main code:
and I just to start off, I made a separate sketch of just my text fading in and out:
I am mostly confused about how to make this into a class and also, whether I would use the mouseClicked() function in my class or in my main code in void draw().
Edit post, highlight code, press Ctrl-o to format
thank you @koogs
I think you are starting at the wrong end. You have tried to get the text to fade, but I think it would be easier to start by making the text appear and disappear then later fade in and out.
If you have an int that keeps track of which line of text you're on, and a boolean to remember if you're fading in or out, you can just check: 1. Am i fading in or out? 2. Fade the number I am on in or out according to 1
@Eeyorelife thank you!
So to start with, you just display the text in your fadeIn or fadeOut functions.
@Eeyorelife ok I'll try it out, thank you
@HANkae -- you may also be interested in this old discussion of several different approaches to fading. Note that this is for continuous progressive fade-out rather than fade-in: