dlobalzo Posted February 18, 2016 Share Posted February 18, 2016 Hi everyone! I'm trying to make a top down racing game, but I can't find a way to make a proper scrolling background. Every example I find is about tiles but my background is not something I can repeat horizontally. The background image is basically the track, so I need that image to be 100% width and repeated vertically, with an infinite vertical scroll. Can you please give me a hint? Thanks in advance! Damian Link to comment Share on other sites More sharing options...
Batzi Posted February 18, 2016 Share Posted February 18, 2016 Did you try tweening it? Link to comment Share on other sites More sharing options...
dlobalzo Posted February 18, 2016 Author Share Posted February 18, 2016 Hi Batzi! No, I didn't but how can I tween something and make it repeat itself when it starts going out of bounds? I've seen a lot of examples with tiles but not exactly what I'm looking for, which I suppose is quite standard, right? Thanks! Link to comment Share on other sites More sharing options...
AzraelTycka Posted February 19, 2016 Share Posted February 19, 2016 Hello, I'm not sure if I get what your problem is, but. If you have an image of background where let's say your road is something like this: h road h h road h h road h h road h If you need to scroll this infinitely then you can just add one more image above this one and do that repeatedly whenever needed. h road h h road h h road h h road h ----------------------- end of the viewport h road h h road h h road h h road h ----------------------- start of the viewport Check when the bottom image's top is lower than vieport's top and then just display the other image above. When the bottom image gets out of bounds you just change it's y coordinate and place it above the one in the viewport, this way you utilize jsut two background images. Bakcground can be moved as mentioned by tweening or just giving it a velocity and tying it with physics engine. PS tiles are not the standard, they are not really necessarry every time. They are handy but use them only when you need it if you are not making a tile based game then you probably don't need most of the tile features ;-). Link to comment Share on other sites More sharing options...
drhayes Posted February 19, 2016 Share Posted February 19, 2016 You probably want a tilesprite. Repeating on the edges is what they do. You could stretch one across the background and then change the tilePosition to make it scroll around. Link to comment Share on other sites More sharing options...
Recommended Posts