guiFont, viewPort not accessible from classes?

Hi,



I’m having trouble accessing guiFont and viewPort from classes. Here is the example from the guiFont



[java]

import com.jme3.font.BitmapText;



public class GUI {



private Main gamePointer;

//protected BitmapText hintText;



GUI(Main game) {

gamePointer = game;

createCrossHair();

}



private void createCrossHair(){

BitmapText ch = new BitmapText(gamePointer.guiFont, false); //Here it says the guiFont has protected access

ch.setSize(guiFont.getCharSet().getRenderedSize() * 2);

ch.setText("+"); // crosshairs

ch.setLocalTranslation( // center

settings.getWidth() / 2 - guiFont.getCharSet().getRenderedSize() / 3 * 2,

settings.getHeight() / 2 + ch.getLineHeight() / 2, 0);

gamePointer.getGuiNode().attachChild(ch);

}

}



[/java]



BitmapText ch = new BitmapText(gamePointer.guiFont, false); //Here it says the guiFont has protected access

anybody knows what I’m doing wrong or how to solve this? :slight_smile:



Thx in advance

In java you normally dont access fields from outside the object, you use getters and setters. So create a getGuiFont and setGuiFont method (jMP can do that for you, just right-click the field, select “Refactor…” then “Encapsulate Field”.