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.

Categories

+8 votes

We're having some trouble figuring out how to get the background image to scroll vertically. Do we need to use a for loop to constantly move the image down? How did you guys go about doing this?

asked in CSC305 Fall 2020 by (1 point)

4 Answers

+4 votes

Our group did it by creating a new variable road_move that was put into a painter method this allowed the graphics of the window to be painted again using "repaint".

answered by (1 point)
+2

Im not sure where the painter method is in javafx, and what type is your variable?

+3 votes

Our group put two images in the background and move it simultaneously making it look like it was in a loop.

answered by (1 point)
+2

You mean two images on top of each other? And how did you move both simultaneously?

+1

One image was off the screen, while the other was on. So, when the first image is slowly moving down, the one that was off the screen will now start appearing at the top. At certain point we reset it so that it keeps looping.

+2

are you changing the coordinates of the picture in order to move it?

+1

Yes, we are changing the coordinates of the image when the player is driving.

+3 votes

We also had two pictures and we were able to move them simultaneously, with the only bad thing being the different bottom and top.

answered by (1 point)
+2 votes

You can try redrawing the image at the top when it goes off the window at the bottom.

answered by (1 point)
...