Hey guys…I’ve fallen off for a little while but getting back into it now…I’m having trouble getting my camera to work right…I have a 30x30 map or 32x32 tiles. I set the screen size to 960x960 as this would show all tiles…When I resize the window, it stretches or makes everything smaller if I make the window bigger or smaller. I’ve been searching for a while and I know it’s something dumb that i’m missing, but I can’t put my finger on it. I’ve got my main class and my map class
public void create() {
float w = Gdx.graphics.getWidth();
float h = Gdx.graphics.getHeight();
float aspectRatio = h/w;
batch = new SpriteBatch();
camera = new OrthographicCamera();
//1 is temporary camera x and y
camera.setToOrtho(false,(w/h)*1,(w/h)*1);
camera.update();
map = new map(camera,"map");
map.setRenderView(camera);
}
map class
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.maps.*;
import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.TmxMapLoader;
import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer;
public class map {
OrthogonalTiledMapRenderer render;
TiledMap currentMap;
MapLayer mLayer1;
float unitScale = 1f/32f;
public map(OrthographicCamera cam, String mapName) {
currentMap = new TmxMapLoader().load("data/test1.tmx");
render = new OrthogonalTiledMapRenderer(currentMap,unitScale);
}
public void setRenderView(OrthographicCamera cam) {
render.setView(cam);
}
public void render(SpriteBatch batch) {
render.render();
}
}
I’ve been messing with the code so much from searching and playing with it that now it seems like it’s rendering 1 HUGE tile to the screen. i’m sure it has something to do with the SetToOrtho call but i’m not exactly sure how to fix it.