Android Game Development Notes (i)

Source: Internet
Author: User

Use of threads

Why do I use threads for Android development games?

Some non-static resources in the game (such as flowing water) need to constantly refresh the canvas (canvas) to achieve the dynamic effect, which requires a timed refresh (even if there is no action), then a thread is required to constantly refresh the canvas to achieve the dynamic effect.

How do I use threads?

Single threaded uses the thread class to instantiate the thread class directly to get a threading object (but this method can only implement one thread object, because Java cannot inherit much, but this is more resource-efficient for programs that require only one thread). Another way is to implement the Runnable interface, which can implement multiple inheritance.


Thread specific use:

In the game to implement the thread's Run () method, often write a dead loop, so that the game logic method is constantly executing to achieve dynamic results. But at the same time, we can set a flag to determine the end condition of the loop, thus making the loop more convenient to control.


This article is from the "11713059" blog, please be sure to keep this source http://11723059.blog.51cto.com/11713059/1870072

Android Game Development Notes (i)

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.