Ok, let me try to shed some more light on the problem itself and explain to you my deduction process.
Here is a list of pretty much everything I did:
Originally I had the array in TextFill, filled it in TextFill and accessed it through a getter and also directly - tf.text.get(0); in GameScreen. That didn’t work out.
I then created the array in GameScreen and tried filling it through setters/public access/getter to no avail.
Lastly, I did all of this, but the main class was in the role of the gamescreen, with no success.
Oh, and let’s not forget I called/filled the array in TextFill’s constructor/separate method/ both and it still did not work.
I know that the size of the array is 0, as I got that error message in the console - array size 0, alongside a null error message several times, but it didn’t seem connected, which led me to believe it’s not being called at all, thus the reason for the, as I like to think of it - straight to the point question.
This is the TextFill class in one of it’s incarnations:
public class TextFill {
// declarations
public ArrayList<String> text = new ArrayList<String>();
private Dealer game;
// constructor
public void fill() {
// fill the array
game.text.add("Michael?");
game.text.add("Michael?!");
game.text.add("Michael...?");
//TODO: add the rest of the text
}
}
This is the GameScreen class with heavily omitted relevant code.
public class GameScreen implements Screen {
private TextFill tf;
// constructor
public GameScreen(final Dealer gam) {
this.game = gam;
// text
tf = new TextFill();
// Lot's of working declarations omitted from code.
}
// render
@Override
public void render(float delta) {
// screen clear, camera update, batch preparation, camera adjustment
// batch
game.batch.begin();
// text
game.font.draw(game.batch, game.text.get(0), 350, 100);
// picture/text drawing
// end batch
game.batch.end();
// a ton of @Override methods
}
// And finally the main class, in which I tried the same things I did to GameScreen. This is just one of it’s forms.
public class D extends Game {
public ArrayList<String> text = new ArrayList<String>();
public TextFill tf;
public void create() {
tf = new TextFill();
tf.fill();
Texture.setEnforcePotImages(false);
batch = new SpriteBatch();
// using the default font
font = new BitmapFont();
// http://code.google.com/p/libgdx-users/wiki/ScreenAndGameClasses
// TODO: use the same screen
this.setScreen(new MainMenuScreen(this));
}
// render
public void render() {
super.render();
}
// dispose
public void dispose() {
batch.dispose();
font.dispose();
}
}
I hope this shed some more light on the problem.