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.