So here’s the code for my infinite scroller, it uses basically 2 objects with sprites attached and just scrolls them infinitely. But in this image you can see the problem? I’ve programmed this many times before, and I feel like I’m missing something stupid, but I can’t for the life of me figure it out.
function init(self)
self.width = 1000
self.edge = 0 - self.width / 2
self.speed = 600
end
function update(self, dt)
fg1Pos = go.get_position("fg1")
fg2Pos = go.get_position("fg2")
fg1Pos.x = fg1Pos.x - self.speed * dt
if fg1Pos.x + self.width / 2 < self.edge then
fg1Pos.x = fg2Pos.x + self.width
end
fg2Pos.x = fg2Pos.x - self.speed * dt
if fg2Pos.x + self.width / 2 < self.edge then
fg2Pos.x = fg1Pos.x + self.width
end
go.set_position(fg1Pos, "fg1")
go.set_position(fg2Pos, "fg2")
end