How to create an infinite scrolling background



Attached Files

The following files have been attached to this tutorial:



Download now 188.33 KB


20,830 visits, 54,549 views



This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Section 2

The script

Alright now that you have it setup, you need to enter the following into your script.

Add new global variable > ScrollSpeed = 200 (for now).

After that is done you need to do this.

System > Every tick - TiledBackground > Set (either X or Y depending on moving up or down, left or right) > TiledBackground.(X or Y depending on what you're setting) + (dt*ScrollSpeed).


System > Every tick - TiledBackground > Set Y > TiledBackground.Y+(dt*ScrollSpeed)

Now you we need to reset the Y or X, depending on which way you're moving it, back to 0. To do this we just do the following:

TiledBackground > Compare either X or Y depending on moving up or down, left or right > Depending on left or right, up or down decides whether it's Greater than or less than, moving up would be less than, down is greater than, right is greater than, left is less than ALL SHOULD BE GREATER THAN OR LESS THAN 0 then for the action Set X or Y to whatever the original X or Y is set at.

Now to decide on what ScrollSpeed should be set at, import Keyboard and script the following.

Keyboard > On Key Pressed > Right Arrow - Add 100 to ScrollSpeed

Keyboard > On Key Pressed > Left Arrow - Subtract 100 from ScrollSpeed

Now just find what number you prefare and change the default value of ScrollSpeed to the new number. Setting Text to ScrollSpeed can help you find the number if you can't go down in 100s ;)


  • Order by
Want to leave a comment? Login or Register an account!