basically what the title says. Loooking to create planets suns, moon in sky which stays centered in background while the stars/ tress move in the foreground.
In one of my current projects, I created a moon on 2040x1280 png, tile image at about 800 and scroll speed set at 0.02
tile image at about 800 or 900, set the scroll speed to about 0.02 to have that realistic moon follow
Image needs to be as big as the screen size -- as @Kadri246 suggested that earlier... Alternatively you can add a picture to the game field, but that is more like a hack to be honest. Another hack is when you have constant game speed and at the start screen you have the sun/moon objects traveling to the game direction so that it looks like stationery Ok, last hack: Attack Moon/Sun to the player object -- but that can have really weird effects
While experimenting with this same idea, What i found was best is keep BG scrolling and add Moon/Sun as an object, make it have no collision, put it high up and adjust its speed and angle to go in the direction you run. Or slow it down ever so slightly so the moon/sun slowly moves to the left as you play. If it a game where you can stop, then they will zoom to the right out of screen. But if its a game where you keep going and when you get hit you die. it will still keep going but all you have to do is make death delay 0 and make sure your game over screen has a background to hide the fact the moon/sun just turbo boosted out of screen lol. Works a charm.
The Sun just gets repeated in the background.... One way around it would be to play around with the Tiling Offset and Speed to match your level length.