Attach a script to your Background node
Attach a script to your Background node
We need a reference variable to the TextureRect to access:
We need a reference variable to the TextureRect to access:
the position property of the TextureRect
the position property of the TextureRect
the Texture property of the TextureRect
the Texture property of the TextureRect
We need variables to keep track of
We need variables to keep track of
the starting X and Y positions.
the starting X and Y positions.
So that we can reset the tile once it has moved a certain distance.
So that we can reset the tile once it has moved a certain distance.
As the scene becomes ready:
As the scene becomes ready:
Capture & store the current x position
Capture & store the current x position
Capture & store the current y position
Capture & store the current y position
Create a function to move the tiles:
Create a function to move the tiles:
Move the tiles (Diagonally):
Move the tiles (Diagonally):
LEFT & UP
LEFT & UP
The tiles are 64 pixels wide.
The tiles are 64 pixels wide.
Once they have moved 64 px from their starting position
Once they have moved 64 px from their starting position
We move them back to their starting position.
We move them back to their starting position.
With ONE tile it would look like this:
With ONE tile it would look like this:
Call the move_tiles() function in _process to make it loop
Call the move_tiles() function in _process to make it loop
If you want to load a different tile using code.
If you want to load a different tile using code.
You can load a different texture.
You can load a different texture.