Treating Table/Array like a display group

Hi all…

I’ve never used spawned tables before, so I feel like a bit of a noob… I’m creating an infinite runner styled thingy, so my ‘floor’ uses a lot of spawned images (that are also physics objects).

To cut a long story short, I want to scroll the floor as if it was a display group (I can’t actually move the display group as it affects the character - which I want to remain in the middle of the screen).

Can I apply a transition to the table itself, or the indexed objects within (all at once)??

At the moment, this is the core part of the code

local platform = {} for i = 1,20 do platform[i] = display.newRect( 568, 500, 50, 50) platform[i].x = (i\*50) platform[i]:setFillColor( 1, 1, 1 ) platform[i].strokeWidth = 1 platform[i]:setStrokeColor( 0, 0, 0 ) physics.addBody( platform[i], "static", { density=2, friction=0.3, bounce=0.0 } )

I simply want to perform a transition (or linear impulse / velocity ((anything really))) on 'platform[i], but I don’t know which part of the table structure to affect, for example, this won’t work:

transition.to( platform[i], { time=150, x=platform[j].x+50, y=0, } )

Help. Thanks :slight_smile:

What you are interested in is setting up a “Camera”.  It lets the world move about the player.

See:  http://code.coronalabs.com/code/perspective-virtual-camera-system

Rob

Hi Rob, I looked into this as an option but thought it was group orientated. Assuming I can separate my objects within a group, it might just be a miracle cure. I’ll let you know. Thanks.

You should also take a look at the below app tutorial, wherein they create an endless runner. It’s pretty old, but the theory is still sound.

http://code.tutsplus.com/series/corona-sdk-build-an-endless-runner-game-from-scratch–mobile-22913

The perspective library is epic, I suspect I’ll be using this a lot!

…Although I’m still trying to figure out how to get it to track on X-Axis only

Caithan,

Use   camera:setBounds(x1, x2, y1, y2).  if you want to restrict the camera to the X axis only, set both y1 and y2 to same value. 

Santi

What you are interested in is setting up a “Camera”.  It lets the world move about the player.

See:  http://code.coronalabs.com/code/perspective-virtual-camera-system

Rob

Hi Rob, I looked into this as an option but thought it was group orientated. Assuming I can separate my objects within a group, it might just be a miracle cure. I’ll let you know. Thanks.

You should also take a look at the below app tutorial, wherein they create an endless runner. It’s pretty old, but the theory is still sound.

http://code.tutsplus.com/series/corona-sdk-build-an-endless-runner-game-from-scratch–mobile-22913

The perspective library is epic, I suspect I’ll be using this a lot!

…Although I’m still trying to figure out how to get it to track on X-Axis only

Caithan,

Use   camera:setBounds(x1, x2, y1, y2).  if you want to restrict the camera to the X axis only, set both y1 and y2 to same value. 

Santi