I am (trying to) making a simple boardgame. Its UI should be very simple, a top component representing a drawing of the board itself, and on the bottom, a few TextViews giving some relevant info (turns, number of tokens on the board, current player, …).
I have an Activity, with:
- A
Gamemember, which handles all the logic. - A
BoardViewextendingView, to draw the game board, which handles the interaction. TextViews which should show some additional interaction.
So the BoardView and TextView instances need to access info from their sibling Game. How shall I access it?
You can either construct both classes
BoardViewandTextViewwith the sameGameinstance,or make
Gamea singleton which holds its own instance.Then you can get the same game instance in both classes by calling