11 flash game development CPU Optimizations

Source: Internet
Author: User

1. Flash player10.1 introduces two features to reduce CPU processing. One is sleep mode, and the other is that SWF Content is located outside the screen to pause and resume the content.

2. in sleep mode, the rendering is paused and the stage. framerate is set to 4fps. Instead of 0, all connections are kept open (netstream, socket
And netconnection ). 4 is because many phone manufacturers use this frame rate as the refresh rate

3. Pause and resume. When the content is outside the screen (all content is outside the screen), pause SWF.
File
, Restores SWF within the screen to limit CPU usage.

4. As a result, SwF is located outside the screen in two cases: first, scroll the page, and second, switch to the new tab in the browser. Haspriority html
When the parameter is set to true, the execution of the Event code is not paused. Whether set to true or false
SWF is reduced to 2 FPS. Rendering will be paused in either case.

5. to freeze and unfreeze a display object, you must use the removed_from_stage and added_to_stage events for the Display object.
To be frozen and restored. This means that when the Display object is removed from the display list, its event must be removed. If it is not removed, the execution will continue, such as enter_frame, which will consume CPU and affect the efficiency.

6. Automatic freezing. In flash player10 and later versions, when an empty frame is encountered, the system will automatically freeze the frame. You do not need to manually remove the listener.

7. Loader
Flash
Player
9. Use unload to freeze the file. Flash player10 introduces a new method called unloadandstop () to freeze the file. This method uninstalls the SWF file, automatically freeze each Display object in SWF and forcibly execute garbage collection.

8. About movieclip and Sprite
Mouse
When you do not need a mouse event, set mouseenabled and mousechildren to false. Continuously detecting mouse Interaction Events will consume CPU usage, especially when a large number of interactive objects overlap.

9. For non-
Animation
Content, the timer is preferred, rather than the event. enter_frame event.

10. In the enterframe event or timer processing function, minimize changes to the appearance of the display object that can cause the screen to be repainted.

11. Try to reduce the animation to save more CPU processing.

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.