Hello! Me and my friend have recently begun working on a platformer and we decided we wanted a tiled map. Problem is, I've never made a platformer in my life and have no idea how tile maps or gravity even works in this situation. My problem is that I've created a tiled map in TILED, but putting it into libgdx does nothing (That I can see). Nor is there a way to set the tiled maps position. Below is the mess of code that I've created. Also, I'm just using a .tmx file and a grass spritesheet that it asks for.
public class GameScreen implements Screen {
GameCore gameCore;
private HUD hud;
private Texture skyTexture;
private SpriteBatch batch;
private TiledMap level1;
private TiledMapRenderer mapRender;
private OrthographicCamera camera;
private TmxMapLoader mapLoader;
public GameScreen(GameCore gameCore){
this.gameCore = gameCore;
}
@Override
public void render(float delta) {
cameraMove();
camera.update();
batch.begin();
batch.draw(skyTexture, 0, 0);
batch.end();
mapRender.render();
hud.render();
}
public void cameraMove(){
if(Gdx.input.isKeyPressed(Keys.A)){
camera.translate(-10, 0);
}
if(Gdx.input.isKeyPressed(Keys.D)){
camera.translate(10, 0);
}
if(Gdx.input.isKeyPressed(Keys.W)){
camera.translate(0, 10);
}
if(Gdx.input.isKeyPressed(Keys.S)){
camera.translate(0, -10);
}
}
@Override
public void resize(int width, int height) {
}
@Override
public void show() {
camera = new OrthographicCamera();
camera.zoom = 1;
batch = new SpriteBatch();
hud = new HUD();
skyTexture = new Texture(Gdx.files.internal("data/Graphics/World/BackGroundSky.png"));
mapLoader = new TmxMapLoader();
level1 = mapLoader.load("data/Maps/Lvl1.tmx");
mapRender = new OrthogonalTiledMapRenderer(level1);
}