Optimization Strategies in android game development

Source: Internet
Author: User
Tags android games

Drawing optimization:
1. Dirty rectangle: it is a waste to redraw the entire background image every time. In fact, only a few of the two frames have changed, therefore, only the changed part can be repainted. This is a common method of drawing optimization. It should be noted that android uses double buffering. That is to say, when using dirty rectangles, the surface must be refreshed twice in a row.
2. Volume screen: this is a common method. cache the entire background image and abstract a visible window. Only the content in the window is displayed. The movement direction of the window is the same as that of Sprite, it is in the opposite direction of the background movement. The background image resolution of Android games is generally the same as that of the screen. This method is rarely used.

 

Engine Optimization:
1. Streamline job-based resources: Simply put, resources are integrated, and unused resources are released in a timely manner. The required resources are reloaded, similar to the pipeline production process. For example, when a game is loaded, all the music or image resources that cannot be used by the current level (scenario, mode, etc.) are released, and only the required resources are loaded. threads that cannot be used are not loaded, don't let it sleep, you must take it out; if some resources only get a part, split it and load only the required part.
2. State transfer logic: Before Game Development, you must understand the state transfer. Redundant State changes will consume the overall performance of the framework, the impact on the smoothness of the game and the cost of subsequent modifications often far exceed expectations. Do not be afraid of effort. Be sure to carefully optimize the status transfer process. In addition, switching between activities, UI threads, and game threads is time-consuming and should be avoided as much as possible.

Game logic optimization:
1. Preprocessing: preprocessing operations in game logic as much as possible. For example, a random number is often used in a game. before the game starts, enough random numbers should be generated for the game logic to call, and the system's rand () function should be avoided. This optimization method is difficult, but is often the most effective way to break through the bottleneck.
2,AlgorithmOptimization.
3. Syntax optimization: the syntax also has a great impact on the Running Speed, such as the for loop. The time overhead varies greatly with different writing methods.

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.