Assume that the objects in the game are the GameObject
class, each object has a Depth
field — the depth, based on which the objects overlap each other as layers with depth, the object with the highest depth will be drawn.
Пример: '.' - глубина 0, 'А' - глубина 1, '@' - глубина 2
(one)
..... ..@.. .A... .....
When you move '@' to the cell 'A', it draws '@'
(2)
..... ..... .@... .....
How to implement storage and checking for depth? So that after the reverse transition 2-> 1 the cell with 'A' was redrawn and stored in memory. There was an idea with ArrayList<GameObject>[]
, but as it seems to me this is a very crooked solution