Hi, I’m just starting out with Defold and I am stuck right at the start where we have the script for moving the ground. I looked at the video and the ground is moving continuously and the image is repeated. In my game, this isn’t happening and all the ground objects move to the back of the screen instead.
Here is an image of my ground collection:
And my code is
`local pieces = {“ground0”,“ground1”,“ground2”,“ground3”,“ground4”,“ground5”,“ground6”}
function init(self)
self.speed = 6
end
function update(self, dt)
for i, p in pairs(pieces) do
local pos = go.get_position(p)
if pos.x <= -228 then
pos.x = 1368 + (pos.x + 228)
end
pos.x = pos.x - self.speed
go.set_position(pos, p)
end
end
Here is an image to help see my problem better
Solution:
I ordered the sprites one after the other using the sprite’s X position instead I should’ve used the game object’s X position