In a method of a custom class View:
public class View {
private Timer timer;
...
private double[][] allLevels;
...
I have a method with an abstract call that needs to point to the variable allLevels. The variable is produced by another class GameLogic, but in the Main of the application. In the Main, the return argument from a public method is then passed to the View:
public class Game extends ApplicationAdapter {
View view;
GameLogic gameLogic;
@Override
public void create () {
System.out.println("Creating");
this.gameLogic = new GameLogic();
this.gameLogic.prepareStimulus();
}
@Override
public void render () {
Gdx.gl.glClearColor(0.5f, 0.5f, 0.5f, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
this.view = new View();
this.view.presentStimulus(this.gameLogic.allLevels);
}
}
Because of a very complex game/business logic I thought I would try to separate and encapsulate as much as possible in a MVC-ish pattern. The Main uses libgdx, which requires create and render to be separate.
My main problem is that I am unable to reach the variable in the class View from the abstract call to the class scope.
public void presentStimulus(double[][] allLevels){
...
timer = new Timer();
...
timer.scheduleTask(new Task(){
@Override
public void run(){
DO SOMETHING WITH that.allLevels[0][0]
}
}, .....);
I have looked at a similar issue, but I guess my question is more basic.
The IDE is unable to autocomplete the reference to the properties using the keyword "this". How can I make the Run() method access the property of the instance of the outer class?