Code for U3L13 page 3

I am looking for the javaScript that allows the words to move with the sprite as seen in the example on page 3. Can someone tell me how this is done? Thank you

@colglazierj, I’m guessing it wasn’t done with javascript, but rather with variables. I’ll refer to the vertically scrolling text, (but a similar concept would explain the jittery text as well).

If instead of specifying a precise y value for the text, you were to set the y value of the text to be equal to a variable (ylocation), you could then update the value of the ylocation variable inside the draw loop … (ylocation = ylocation -1); This would then cause the text to move vertically across the screen.

Here’s a working example (using horizontally scrolling text).

Hope this helps!


1 Like