I have 4 display object called t1, t2, t3, t4.
They are actually 4 squares which will be displayed on the screen. Each square has different colors.
For example, T1 (red), T2 (green), T3 (blue), T4 (yellow).
When user swipe left, all four squares which are lined up in a row will move to the left.
That means T1 (red) will move off the left side of the screen.
The moment T1 start to touch the left side of the screen, I want it to start appearing on the right side of the screen. So the whole row of squares can be continuously swiped and repeat themselves.
What I did is, I created another 2 squares, one at the left side, one at the right side. They are off the screen so user cannot see them at first. Let’s call them T0 & T5.
Then I wrote some code so make T0 color equal to T4. and color of T5 similar with T1.
So when user swipe left, T5 which is also RED color will appear from he right. This gives the impression that the squares are continuous.
What is the best way to shift items in the array left or right? If my table gets larger and larger, I no longer can write a primitive code which manually shift the individual items in the table. I need an algorithm.