Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.


+8 votes

i made a while loop that will run infinitely with a for loop inside that will scroll the background by constantly changing the y coordinates of two images stacked on top of each other to create a scrolling effect. then i reset the positions of the two images, except the loop causes the game to give a "not responding" and will never start. did you guys put the loop before stage.show() or after? and did you guys make an infinite loop too? im not sure why mine isnt working

closed with the note: I figured it out a few weeks back using transitionsbut forgot to close this questions. Thanks for the answers though.
asked in CSC305 Fall 2020 by (8 points)
closed by

4 Answers

+3 votes

We don't have a while loop for ours. We created our background as an imageview(actually two imageviews so the scrolling was more seamless) and scrolled the imageview in the background during the animation timer. Then we recalculated the position if it was below the view of the window

answered by (8 points)
+3 votes

My group has an starting image which scrolls down the page and a second instance of the same image above the first one which also scrolls down. When the first image gets to the bottom of the window, it is set above the second image. When the second image gets to the bottom of the window, it is set above the first image. This continuously repeats for the game. There is a bit of overlap but we have the background continuously scrolling.

answered by (2.4k points)
+3 votes

We don't have a while loop though we used an animation timer. We set the background as two separate ImageViews, to make the transition seamless from on to another, and we recalculated the position when the top of the view was at the bottom of the window.

answered by (8 points)
+2 votes


Check out this post. It's using an AnimationTimer to loop the game and you can add the second image and reset the coordinates to get a smooth transition.

answered by (2.3k points)