Try using one function for all grass:
function scrollGrass(grass)
if grass.x < (-1000 + (grass.speed*3)) then
grass.x = 1000
else
grass.x = grass.x - grass.speed
end
end
function scrollGrasses(event)
scrollGrass(grass1)
scrollGrass(grass1_duo)
scrollGrass(grass2)
scrollGrass(grass2_duo)
end
Runtime:addEventListener("enterFrame",scrollGrasses)
If that doesn't help, it may well be that your scroll function is wrong, but it's impossible to tell from your post, what you are wanting that function to do.
Update:
First thing you should try is not register for enterFrame events, so you see the grass as it is initialized. Are the positions correct?
The other thing you could do is use a transition on a group, then you won't need enterFrame:
allGrasses = display.newGroup()
allGrasses:insert(grass1)
...
allGrasses:insert(grass2_duo)
function resetGrassesPos()
allGrasses.x = 0
transition.to(allGrasses, {time=5000, x=-500, onComplete=resetGrassesPos}
end
transition.to(allGrasses, {time=5000, x=-500, onComplete=resetGrassesPos}
You could have a transition for each individual grass but I don't know if it would keep them in sync.