This question is different because it's about creating a 3D world editor.. at the moment I want to get the updated positions of my models to work..
so I've worked my way up to a rather simple problem. In order to update the scene I want to have a boolean look if a specific input was given and then change from false to true once this input was given.. my problem though is that the Input method has to be in another class and I don't know how I can affect the boolean from there.. here's the code:
public class EngineSetup extends Game
{
public boolean doStuff = true;
public void Init()
{
CreationTool updateCoords = new CreationTool(this);
while(doStuff == true) { updateCoords.Environment(); doStuff = false; }
}
}
This is what happens when the engine starts. It's going to run the Environment method in my CreationTool class only once, because after the first execution doStuff changes to false.
public class CreationTool extends GameComponent
{
public void Input(float delta)
{
if(Input.GetKeyUp(getCoords))
// change the boolean value in EngineSetup to true
}
}
In the CreationTool class I have this Input method and getCoords is just a variable for the enter key.
So the idea is once I hit the enter key the boolean in the EngineSetup class is set to true and the Environment method is being executed once again and the boolean is changed back to false again.
How can I change the boolean value from within the CreationTool class as decribed above?
Thanks a lot for any help!
EDIT: I've gotten some answers but none of them worked..
public class EngineSetup extends Game
{
private static EngineSetup INSTANCE;
public boolean doStuff = true;
public void Init()
{
INSTANCE = this;
CreationTool updateCoords = new CreationTool(this);
while(doStuff == true) { System.out.println("Work"); doStuff = false; }
}
public class CreationTool extends GameComponent
{
public void Input(float delta)
{
if(Input.GetKeyUp(getCoords))
{ EngineSetup.getInstance().doStuff=true; }
}
}
It works the first time around when the program starts but when I hit the enter nothing happens.
public class EngineSetup extends Game
{
public static boolean doStuff = true;
public void Init()
{
CreationTool updateCoords = new CreationTool(this);
while(doStuff == true) { System.out.println("Work"); doStuff = false; }
}
public class CreationTool extends GameComponent
{
public void Input(float delta)
{
if(Input.GetKeyUp(getCoords))
EngineSetup.doStuff = true;
}
}
Also this didn't work, the first time around when the program start everything's fine but when I hit enter: nothing..
How to fix..?