Unit 3: animation


#1

Can you animate text or just sprites? I have a student that wants to make text move across the screen. We are unsure on how to do that.


#2

Create a variable for the x position of the text such as:

var textStart = -200 (off the screen)

Then, when you place the text, place it inside the draw loop using the variable you created as the x position and then increment the variable… the code below would cause it to scroll left to right across the screen.

textSize(20);
text(“Once there was a fisherman …”, textStart, 375);
textStart=textStart+3;


#3

Here’s a working program … this one starts on the right side and scrolls left for better readability…


#4

thanks! Much appreciated. :slight_smile: