Ok so I followed some tutorials and bascially I have come to a conclusion that I need to work with .tmx files regarding tiles and maps.
Now, I have created a simple orthogonal tile with Tiled software and included it in my asstets (.tmx file). I use TiledMap objects to represent the map I work with but the problem is it only contains one tile.
How can I render the tiles all over the screen so that they will cover all the screen size?
Here is a screenshot of my app:
And here is my renderer code:
package graphics;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.TmxMapLoader;
import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer;
public class GameRenderer extends Renderer{
private TiledMap map;
private OrthogonalTiledMapRenderer renderer;
public GameRenderer() {
super();
}
@Override
public void init() {
TmxMapLoader loader = new TmxMapLoader();
map = loader.load("map/bg_tile.tmx");
renderer = new OrthogonalTiledMapRenderer(map);
camera = new OrthographicCamera();
camera.setToOrtho(false);
}
@Override
public void render() {
Gdx.gl.glClearColor(0, 0, 0, 0);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
renderer.setView(camera);
renderer.render();
}
public void resizeCamera(float width, float height) {
camera.viewportWidth = width;
camera.viewportHeight = height;
camera.update();
}
@Override
public void dispose() {
super.dispose();
map.dispose();
renderer.dispose();
}
}