Hey guys, this is the 1st time i’ve posted and i’m rather new to JME3. I’m having problems updating my HUD text using in simpleUpdate- hudText.setText(“Position: 2”); - the code wont build because the symbol hudText is not found, but it is created in simpleInitApp. The text displays if i comment out the line in simpleUpdate, but wont build if it is included. I’m assuming it is because the variable used for the HUDtext is in a different class but i’m having trouble finding the correct place create the HUDtext.
Any help and assistance will be greatly appreciated
bab2k
You need to put it in the class. If you create it in a method it’ll go away once the method is run. Something like this:
[java]
public class MyGame extends SimpleApplication {
protected BitmapText hudText; // Declare it here.
public void simpleInit(){
hudText = new BitmapText(blabla,blabla); // Initialize here.
}
public void simpleUpdate(float tpf){
hudText.setText(“blablab”);
}
}
[/java]
hudText should show in green then, as it’s a part of the class. Maybe do a search on classes and member variables. And “scope”.
That’s awesome, thanks
much appreciated help
Bab2k7