I'm trying to confirm up my understanding of the coding differences and similarities between mobile game design and mobile app design for Android devices using Java/Kotlin.
~~ ~~ ~~
In mobile app design, a good design principle is "Separation of Concerns" where the app will have any number of distinct classes to handle different purposes. One design architecture separates these concerns into two classes, namely, the "View Model" and the "UI Controller" (where the UI controller is an activity or fragment).
The View Model's purpose is to have code that holds data and makes logical decisions with that data. The UI Controller's purpose is to draw that data on the device's screen, as well as, receive Input and OS events.
~~ ~~ ~~
In mobile game design, I've seen an Activity class, a GameView class (which implements SurfaceView) and a Thread subclass. The Activity will instantiate the GameView class and place the GameView class into its view hierarchy using setContentView(GameView(this))
. This differs from how mobile app design where setContentView(R.layout.layout_xml_file)
is used to supply views
The GameView object has a surface to have bitmaps drawn on. The GameView object manipulates that surface using surface-specific callback functions which is much like how the UI Controller manipulates lifecycle state using lifecycle-specific callback functions. The GameView object also handles User Input like the UI Controller.
Obviously, the GameView and the UI Controller have the same roles.
~~ ~~ ~~
- Does a Thread in a mobile game serve the same purpose as a View Model in a mobile application?
- If not, where are is the data and logical decisions supposed to go? Do they go in the various Bitmap classes?
- If Bitmap classes serve the same function as View Models, how do they make logical decisions (i.e. a Mario object collects a Coin object)?