To my knowledge there isn't anything in Godot that does it automatically, except for backgrounds using the ParallaxBackground
and ParallaxLayer
nodes. But this is a pretty simple thing to do. Basically, you define the boundaries of your world, and then just test to see if objects are over those boundaries, and if they are, move them around. In essence (assuming the boundaries are the size of the screen):
if position < 0:
position = screen_size
elif position >= screen_size:
position = 0
(you test that after you move the object)
You can do that for both the x
and y
if you need objects to wrap in both directions. However, that code above will work if the origin is in the center of the object (which is the default in Godot). In case you make it the top-left, for example, then you'll have to take into account the size of the sprite and do readjustments, depending on whether you want the sprite to fully disappear before jumping to the other side, or jump as soon as it touches the border. You could something like...
elif position < 0:
position = screen_size - sprite_width
if position >= screen_size - sprite_width:
position = 0
...to make it jump as it touches the boundary. You can do that for anything that needs to wrap around, and if you wrap scenes around, everything in them will follow suit, so you can also play around with that.
For levels, I'm not sure how to do it, but I suppose you could do that for each part of it. Just make sure the parts jump around outside the screen, or otherwise the player will see them popping up as he goes.