Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java LibGDX BitmapFont setScale method not working

Tags:

java

libgdx

I am currently trying to scale a font but I am receiving the error "the method setScale(float, float) is undefined for the type BitmapFont" This is the code section where I am getting the error, specifically in lines 2 and 4.

    font = new BitmapFont(Gdx.files.internal("text.fnt"));     font.setScale (.25f, -.25f);     shadow = new BitmapFont(Gdx.files.internal("shadow.fnt"));     shadow.setScale (.25f -.25f); 

I created the variables here

  public static  BitmapFont font; public  static BitmapFont shadow; 

When I check other examples of using the setScale function, this seems to be the format used. Any ideas as to why this is occurring?

like image 833
BlastBeats Avatar asked Apr 23 '15 06:04

BlastBeats


1 Answers

This method doesn't exist anymore in the BitmapFont class.

An API change for the Bitmap* classes has been introduced with LibGDX 1.5.6 (released in April 2015) as explained in this libgdx team blog post. The tutorial you followed is probably now outdated.

Long story short, with the latest libgdx version, you should be able to do :

font.getData().setScale(.25f,.25f); 
like image 132
Khopa Avatar answered Sep 17 '22 21:09

Khopa