fix: correction du viewport et ajout camera pour resolution adaptée.
This commit is contained in:
parent
89523367b9
commit
c1057f706d
|
@ -36,6 +36,7 @@ public class AssetLoader {
|
||||||
public static boolean stretch=false;
|
public static boolean stretch=false;
|
||||||
public static Preferences prefs;
|
public static Preferences prefs;
|
||||||
public static ScalingViewport viewport;
|
public static ScalingViewport viewport;
|
||||||
|
public static OrthographicCamera Camera;
|
||||||
|
|
||||||
public static void addstyle(TextureAtlas Atlas_level,String Name) {
|
public static void addstyle(TextureAtlas Atlas_level,String Name) {
|
||||||
AtlasRegion AnAtlasRegion = Atlas_level.findRegion(Name);
|
AtlasRegion AnAtlasRegion = Atlas_level.findRegion(Name);
|
||||||
|
@ -100,12 +101,15 @@ public class AssetLoader {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Gdx.app.debug("AssetLoader","Ratio 16/9, résolution virtuelle : 1920x1080.");
|
Gdx.app.debug("AssetLoader","Ratio 16/9, résolution virtuelle : 1920x1080.");
|
||||||
|
Camera = new OrthographicCamera(width,height);
|
||||||
|
Camera.position.set(width/2, height/2, 0);
|
||||||
|
Camera.update();
|
||||||
if (stretch) {
|
if (stretch) {
|
||||||
viewport = new StretchViewport(realWidth,realHeight);
|
viewport = new StretchViewport(width,height);
|
||||||
Gdx.app.debug("AssetLoader","Adaptation d'écran maximale, 'Aspect-Ratio' non conservé.");
|
Gdx.app.debug("AssetLoader","Adaptation d'écran maximale, 'Aspect-Ratio' non conservé.");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
viewport = new FitViewport(realWidth,realHeight);
|
viewport = new FitViewport(width,height);
|
||||||
Gdx.app.debug("AssetLoader","Adaptation d'écran totale, 'Aspect-Ratio' conservé.");
|
Gdx.app.debug("AssetLoader","Adaptation d'écran totale, 'Aspect-Ratio' conservé.");
|
||||||
}
|
}
|
||||||
viewport.apply();
|
viewport.apply();
|
||||||
|
|
|
@ -12,8 +12,8 @@ public class main extends Game {
|
||||||
@Override
|
@Override
|
||||||
public void create() {
|
public void create() {
|
||||||
Gdx.app.setLogLevel(AssetLoader.setpref());
|
Gdx.app.setLogLevel(AssetLoader.setpref());
|
||||||
//debug();
|
debug();
|
||||||
test();
|
//test();
|
||||||
Gdx.app.debug(getClass().getSimpleName(), "Récupération de la résolution des préférences.");
|
Gdx.app.debug(getClass().getSimpleName(), "Récupération de la résolution des préférences.");
|
||||||
if (AssetLoader.prefs.contains("ResolutionX") && AssetLoader.prefs.contains("ResolutionX")) {
|
if (AssetLoader.prefs.contains("ResolutionX") && AssetLoader.prefs.contains("ResolutionX")) {
|
||||||
try {
|
try {
|
||||||
|
@ -38,8 +38,8 @@ public class main extends Game {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void debug() {
|
public void debug() {
|
||||||
AssetLoader.prefs.putInteger("ResolutionX", 1280);
|
AssetLoader.prefs.putInteger("ResolutionX", 640);
|
||||||
AssetLoader.prefs.putInteger("ResolutionY", 1024);
|
AssetLoader.prefs.putInteger("ResolutionY", 200);
|
||||||
AssetLoader.prefs.putBoolean("Fullscreen", false);
|
AssetLoader.prefs.putBoolean("Fullscreen", false);
|
||||||
AssetLoader.prefs.putBoolean("VSync", false);
|
AssetLoader.prefs.putBoolean("VSync", false);
|
||||||
AssetLoader.prefs.putInteger("log", Gdx.app.LOG_DEBUG);
|
AssetLoader.prefs.putInteger("log", Gdx.app.LOG_DEBUG);
|
||||||
|
@ -48,8 +48,8 @@ public class main extends Game {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void test() {
|
public void test() {
|
||||||
AssetLoader.prefs.putInteger("ResolutionX", 1280);
|
AssetLoader.prefs.putInteger("ResolutionX", 1920);
|
||||||
AssetLoader.prefs.putInteger("ResolutionY", 1024);
|
AssetLoader.prefs.putInteger("ResolutionY", 1080);
|
||||||
AssetLoader.prefs.putBoolean("Fullscreen", true);
|
AssetLoader.prefs.putBoolean("Fullscreen", true);
|
||||||
AssetLoader.prefs.putBoolean("VSync", true);
|
AssetLoader.prefs.putBoolean("VSync", true);
|
||||||
AssetLoader.prefs.putInteger("log", Gdx.app.LOG_INFO);
|
AssetLoader.prefs.putInteger("log", Gdx.app.LOG_INFO);
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class SplashScreen implements Screen {
|
||||||
public SplashScreen(main game) {
|
public SplashScreen(main game) {
|
||||||
this.game = game;
|
this.game = game;
|
||||||
AssetLoader.load();
|
AssetLoader.load();
|
||||||
stage = new Stage();
|
stage = new Stage(AssetLoader.viewport);
|
||||||
splashImage = new Image(AssetLoader.Texture_logo);
|
splashImage = new Image(AssetLoader.Texture_logo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ public class LevelRenderer {
|
||||||
batcher2 = new SpriteBatch();
|
batcher2 = new SpriteBatch();
|
||||||
shapeRenderer = new ShapeRenderer();
|
shapeRenderer = new ShapeRenderer();
|
||||||
Laser=new Laser();
|
Laser=new Laser();
|
||||||
|
AssetLoader.viewport.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void evolve() {
|
public void evolve() {
|
||||||
|
@ -68,6 +69,7 @@ public class LevelRenderer {
|
||||||
//Gdx.gl.glViewport(0, 0, AssetLoader.width, AssetLoader.height);
|
//Gdx.gl.glViewport(0, 0, AssetLoader.width, AssetLoader.height);
|
||||||
|
|
||||||
batcher.begin();
|
batcher.begin();
|
||||||
|
batcher.setProjectionMatrix(AssetLoader.Camera.combined);
|
||||||
batcher.setColor(0.25f,0.25f,0.25f,1);
|
batcher.setColor(0.25f,0.25f,0.25f,1);
|
||||||
batcher.draw(AssetLoader.Texture_fond2, 0, 0, this.scrollx/2, this.scrolly/2, AssetLoader.width, AssetLoader.height);
|
batcher.draw(AssetLoader.Texture_fond2, 0, 0, this.scrollx/2, this.scrolly/2, AssetLoader.width, AssetLoader.height);
|
||||||
batcher.setColor(0.7f,0.7f,0.7f,1);
|
batcher.setColor(0.7f,0.7f,0.7f,1);
|
||||||
|
@ -81,12 +83,13 @@ public class LevelRenderer {
|
||||||
|
|
||||||
Gdx.gl.glEnable(GL20.GL_BLEND);
|
Gdx.gl.glEnable(GL20.GL_BLEND);
|
||||||
shapeRenderer.begin(ShapeType.Filled);
|
shapeRenderer.begin(ShapeType.Filled);
|
||||||
|
shapeRenderer.setProjectionMatrix(AssetLoader.Camera.combined);
|
||||||
shapeRenderer.setColor(0.5f, 0.5f, 0.5f, 0.5f);
|
shapeRenderer.setColor(0.5f, 0.5f, 0.5f, 0.5f);
|
||||||
shapeRenderer.rect(10, 10, 1114, 140);
|
shapeRenderer.rect(10, 10, 1500, 140);
|
||||||
shapeRenderer.rect(1134, 10, AssetLoader.width-1144, 140);
|
shapeRenderer.rect(1500, 10, AssetLoader.width-1500, 140);
|
||||||
shapeRenderer.rect(1134, 160, AssetLoader.width-1144, 140);
|
shapeRenderer.rect(1500, 160, AssetLoader.width-1500, 140);
|
||||||
shapeRenderer.rect(1134, 310, AssetLoader.width-1144, 300);
|
shapeRenderer.rect(1500, 310, AssetLoader.width-1500, 300);
|
||||||
shapeRenderer.rect(1134, 620, AssetLoader.width-1144, AssetLoader.height-620);
|
shapeRenderer.rect(1500, 620, AssetLoader.width-1500, AssetLoader.height-620);
|
||||||
shapeRenderer.end();
|
shapeRenderer.end();
|
||||||
|
|
||||||
batcher2.begin();
|
batcher2.begin();
|
||||||
|
|
Loading…
Reference in New Issue