Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scaling issue with FitViewport #3

Open
bmbariah opened this issue Nov 9, 2016 · 0 comments
Open

Scaling issue with FitViewport #3

bmbariah opened this issue Nov 9, 2016 · 0 comments

Comments

@bmbariah
Copy link

bmbariah commented Nov 9, 2016

I have implemented your lib with my libgdx game but the font scales out of proportion when I use a FitViewport with my own world co-ordinates as shown in the 2 images below.

The first image shows when I don't use my FitViewport and the second one shows when I do. Kindly assist. My entire game uses the FitViewport but text simply isn't sharp...

I simply want the text in my game to scale like the first image but when using a viewport

public class ExampleMain implements Screen {

Start app;

@Override
    public void show() {

        SmartFontGenerator fontGen = new SmartFontGenerator(app);
        FileHandle exoFile = Gdx.files.internal("fonts/OpenSans.ttf");
        BitmapFont fontSmall = fontGen.createFont(exoFile, "exo-small", 24);
        BitmapFont fontMedium = fontGen.createFont(exoFile, "exo-medium", 48);
        BitmapFont fontLarge = fontGen.createFont(exoFile, "exo-large", 64);

       //1st image
       //This one causes text to display correctly but doesn't use the FitViewport
        stage = new Stage();

       //2nd image
         //This one causes text to display incorrectly but uses the FitViewport (
        stage = new Stage(app.viewport);

}

This is how I have set up my viewports...

public class Start extends Game {
 
     public void create()
    {
        screenWidth = Gdx.graphics.getWidth();
        screenHeight = Gdx.graphics.getHeight();
        gameHeight = screenHeight / (screenWidth / gameWidth);
        midPointY = (int) (gameHeight / 2);
        camera = new OrthographicCamera();
        camera.setToOrtho(true, gameWidth, gameHeight);
        //viewport = new ExtendViewport(360, 1, camera);
        viewport = new FitViewport(gameWidth, gameHeight, camera);
        viewport.apply();

ok
resize

Any ideas? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant