I'm working on a game and noticed that adding an object to two arraylists and then updating one of them doesn't update the other. Is it possible to solve this?
I have a list of all tiles which is looped though when rendering. But I also want a list of slots(extends Tile) in my inventory class instead of looping though all game tiles to get the inventory slots.
I have two lists: Game.tiles and Inventory.slots
This is where I add slots (Inventory class):
for(int i = 0; i< 16; i++){
Slot slot = new Slot();
Game.tiles.add(slot);
slots.add(slot);
}
And this is where I modify slots (Inventory class):
for(int i = 0; i< 16; i++){
slots.get(i).visable = false;
}
The problem is that the data updates for the slot in the slots list but not for the same slot in the Game.tiles list.
Full inventory class: http://pastebin.com/KS5BNB3F