Jungle Scene/object.contentWidth

Hello I am new to corona sdk and I am learning through hit and trial in the sample code. One of the sample provided by corona is Jungle Scene, where the pics are moving and a cat chasing after a green dude…

I happen to pass through these codes and I would be grateful if you would explain me these codes…

if (grass.x + grass.contentWidth) < 0 then

      grass:translate( 480 * 2, 0)

end

  

if (grass2.x + grass2.contentWidth) < 0 then

      grass2:translate( 480 * 2, 0)

My first question is what is the function of object.contentWidth does. Please do explain and dnt give the definition already given in the corona website. 

What does grass:translate(480*2,0) mean and why multiple by 2 and not other digit

Does grass.x give the x coordinate of the grass object(middle of the image as coordinate point)

To give the illusion of an endless plain for the characters to run on, the app uses two identical grass textures. Each is the length of the screen’s content area, in this case 480 points.

Each frame we move  the grass to the left. If there was only one grass, there would be a time where no grass was visible, so we move two copies at the same time. One that starts centered on the screen and one that is off screen to the right but bumping up against the first. To create the illusion of endless, we have to move them together. But one one of the grass objects is off screen (grass.x + grass.contentWidth < 0) then we relocate that grass to the far right side of the screen and continue the process.

One of the grass objects is called “grass”, the other is called “grass2”.

Does that help?

Rob

Dear Rob,

Thank you so very much for the help

To give the illusion of an endless plain for the characters to run on, the app uses two identical grass textures. Each is the length of the screen’s content area, in this case 480 points.

Each frame we move  the grass to the left. If there was only one grass, there would be a time where no grass was visible, so we move two copies at the same time. One that starts centered on the screen and one that is off screen to the right but bumping up against the first. To create the illusion of endless, we have to move them together. But one one of the grass objects is off screen (grass.x + grass.contentWidth < 0) then we relocate that grass to the far right side of the screen and continue the process.

One of the grass objects is called “grass”, the other is called “grass2”.

Does that help?

Rob

Dear Rob,

Thank you so very much for the help