Reputation: 2147
I am implementing one game where I want to repeat one image along x direction.I searched for it on the web but could not get the correct approach. There is a grass image and I want to repeat it all along the ground in x direction.
Kindly provide some suggestions and possible ways to do it.
I am using following code to draw Image inside render method.
spriteBatch.draw(grass, 0, 0);
Upvotes: 2
Views: 324
Reputation: 1192
Let's try a simple for loop
for(int i = 0; i <= Gdx.graphics.getWidth(); i += grass.getWidth() {
spriteBatch.draw(grass, i, 0);
}
I assume grass
is an instance of Sprite
. If that doesn't work, don't hesitate to comment back.
Upvotes: 2