Unit 3: animation


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.


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.

text(“Once there was a fisherman …”, textStart, 375);


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


thanks! Much appreciated. :slight_smile: