Android games, android
Segment 1
Android games-Dt (1)
Rule: In the 9x9 chessboard, the 9 grids in each horizontal and vertical columns contain numbers 1 to 9, which are not repeated,
The nine grids enclosed by each black thick line contain numbers 1 to 9, which are not repeated.
Since it involves a board, drawing is indispensable. We know that the drawing work in android is completed by the UI thread,
Generally, it refers to the main thread, while the android system sets the UI drawing thread to report exceptions if it does not respond for more than 5 seconds.
The child thread computes the data and sends the message to the UI thread to update the interface.
In Java, we can use views for plotting. By default, views are lightweight. In android
We can also use the View for plotting, as long as the class we create inherits the View, override the onDraw () method
And then create a new View class instance in the Activity, and instantiate it. Set it in setContentView.
For a small game, its computing workload is also lightweight, which is basically impossible for more than 5s. Therefore, the interface is updated directly in the UI thread.
There is no big problem, but here we try to use a drawing class provided by android to implement the Drawing operation.
YesSurfaceView,This class inherits from View.
Android allows us to plot in SurfaceView first, cache all the items to the Surface, and then in the main thread
Rendering to the screen. For example:
Well, first come here. Next we will use SurfaceView to draw a Sudoku board.