Android games, android

Source: Internet
Author: User
Tags android games

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.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.