From the guide. " Make sure you place “ground.collection” in position 0, 0, 0 or it will be offset visually. Save it."
Here is what I get.
Not like http://www.defold.com/tutorials/images/getting-started/1/scale_ground.png
From the guide. " Make sure you place “ground.collection” in position 0, 0, 0 or it will be offset visually. Save it."
Here is what I get.
Not like http://www.defold.com/tutorials/images/getting-started/1/scale_ground.png
I think you have missed the following instruction in step #4: “Set the X position of the sprite component to 190. That way the pivot of the game object will be at the leftmost edge of the sprite image.”
From the look of your screenshot it seems as though the sprites are centered on the game object instead of having the pivot point at the leftmost edge.
Thanks. I now set all the sprite to my number(750). [1500 is my picture width]
And Set the game object to 0 1500 3000 4500 6000 7500 9000
When don’t scale it it show
But When I scale all of it . It show me up like
This is expected. If you change the scale of the game objects you also need to repositions them again so that they line up. Maybe the tutorial should explicitly state that this is required in step #6 @sicher? In any case, reposition them again and you should be ready to proceed with the next step of the tutorial.
Thanks. I got the right idea.
I still wonder the number we set For example.
My width of picture is 1500. I scale 0.5. So I change the example to this code:
function init(self)
self.speed = 6
endfunction update(self, dt)
for i, p in ipairs(pieces) dolocal pos = go.get_position(p) -- why if pos.x <= -750 then pos.x = 1368 + (pos.x + 750) end pos.x = pos.x - self.speed go.set_position(pos, p) end
end
When I run it .I met this: I can’t make the precise position conect the first one to the last one.
So in the code. how can I compute the number to make the first pciture will connect the last one when the picture is moving?
I find 1368 was the right position of game object . So I change to my posion 4500
function init(self)
self.speed = 6
endfunction update(self, dt)
for i, p in ipairs(pieces) dolocal pos = go.get_position(p) -- why if pos.x <= -750 then pos.x = 4500 + (pos.x + 750) end pos.x = pos.x - self.speed go.set_position(pos, p) end
end
It comes out: So 4500 is too large for it
How many pictures do you have? 6?
What you want to achieve is that when a game object has moved completely out of view across the left edge of the screen then you want to reposition it as the rightmost of the game objects. In the original example each ground piece was 228 pixels wide and there were 6 of them. The number 1368 that was used in the example comes from 228*6.
So, to translate this into something that would work for your project where your images are 750 pixels wide then, assuming you also use 6 game objects, then the value you are looking for should be 750*6 = 4500.
I’m not sure why you are seeing a gap in the images like in your screenshot.
totally 7.
Strange 4500 is right. I re run it. It don’t see any gap now.
Ok, good that you got it to work!