I'm having some trouble with setting texture region to my TiledMapTile. It gives me NullPointerException
and I have no idea why.
Here is some code:
TiledMapTile coinTile;
public void show () {
mapTexture1 = new Texture(Gdx.files.internal("maps/other/texture1.png"));
TextureRegion mapTexture1Region = new TextureRegion(mapTexture1, 32, 0, 16, 16);
coinTile.setTextureRegion(mapTexture1Region);
}
And here is the error:
04-09 21:57:18.222: E/AndroidRuntime(7792): java.lang.NullPointerException
04-09 21:57:18.222: E/AndroidRuntime(7792): at com.never.mind.screens.GameScreen.show(GameScreen.java:225)
which leads to this line:
coinTile.setTextureRegion(mapTexture1Region);