April 2019
Beginner to intermediate
698 pages
15h 15m
English
Now that we have learned about the game loop and threads, we can put it all together to implement our game loop in the Living Drawing project.
We will add the entire code for the game loop, including writing code in two functions in the MainActivity class to start and stop the thread that will control the loop.
Reader challenge
Can you work out for yourself how the Activity-based class will start and stop the thread in the LiveDrawingView class?
Update the class declaration by implementing Runnable, as shown in the following highlighted code:
class LiveDrawingView(
context: Context,
screenX: Int)
: SurfaceView(context), Runnable {Notice that we have a ...
Read now
Unlock full access