Another question - looping a parallaxing background image in TGB
by Josias Gibbs · in Torque Game Engine · 08/08/2008 (7:24 pm) · 9 replies
I'm making a top-down space game, and I have a background image of stars that I've gotten to parallax. My problem is, when you fly your ship off the edge of the star image, there's nothing but blackness. What I'd like to do is make the star background loop (ie: like the overworld of an old RPG, once you cross the edge of the map, you end up on the opposite edge of the map)
Is there an easy way to do this in TGB? If not, then is there a hard way to do this?
Is there an easy way to do this in TGB? If not, then is there a hard way to do this?
About the author
#2
Hmm... I guess what I'm really trying to do is tile the star background (ie: make it repeat over and over again). That way, no matter how far the player flies, there will always be stars behind them. Is there an easy way to do that?
08/09/2008 (12:08 am)
My camera is mounted to the player's ship, and I've got the star background parallaxing (ie: scrolling when the player's ship moves, but slowly, to simulate the stars being far away) Hmm... I guess what I'm really trying to do is tile the star background (ie: make it repeat over and over again). That way, no matter how far the player flies, there will always be stars behind them. Is there an easy way to do that?
#3
I think my first idea of mounting the scroller(s) to the player might work. When you move it moves with you because its mounted, but also scrolls slightly at the same time.
08/09/2008 (12:37 am)
If its a scroller, why would you want to tile it? That sortof defeats the point of a scroller.I think my first idea of mounting the scroller(s) to the player might work. When you move it moves with you because its mounted, but also scrolls slightly at the same time.
#4
08/09/2008 (12:54 am)
My background is actually not a scroller, it's a static sprite. I need to tile it because once your ship flies too far in any direction, it flies off the edge of it.
#5
08/09/2008 (1:14 am)
I don't know of any way to make that work with a static sprite. Try using a scroller.
#6
As far as I know, scrollers only scroll horizontally... but I'm not too familiar with them, so I could be wrong.
Can scrollers do what I'm trying to do? If so, then how? And if not, then how can I do what I'm trying to do?
08/09/2008 (1:26 am)
Hmm - I'm not sure if a scroller can do what I'm trying to do. I'm making a top down space game - kinda like asteroids. When the player's ship is sitting still, the stars sit still too, but when the player's ship moves, the stars in the background move accordingly (ie: if the player moves to the northwest, then the stars move to the northwest too, but at a slower speed than the player is moving) I got this working easily using the parallax behavior on this site, but my problem is that eventually the player makes it to the edge of my starfield, and flies off into blackness.As far as I know, scrollers only scroll horizontally... but I'm not too familiar with them, so I could be wrong.
Can scrollers do what I'm trying to do? If so, then how? And if not, then how can I do what I'm trying to do?
#7
08/09/2008 (1:38 am)
All I can say is look at the documentation to find the methods a t2dScroller has and try using it. It looks to me like it can do exactly what you want.
#8
its been a while since i used tgb but thats how i did it.
hope that helps you out
08/09/2008 (1:55 am)
Try Using a tile layer on wrap, and set the pan speed etc based on the player velocity and update per tick.its been a while since i used tgb but thats how i did it.
hope that helps you out
#9
08/09/2008 (2:43 am)
GOT IT! - I used a scroller, set the size to 12800 by 12800, and set the repeat to 100, and voala! - my 128 by 128 image was transformed into a massive starfield.
Associate James Ford
Sickhead Games
Or do you mean something like the "WorldLimitWrapBehavior" thats on the TDN?