Android's View/surfaceview/glsurfaceview

Source: Internet
Author: User
Tags android games

The main addition to the control class in Android games is the Display Class View. Surfaceview is a display class that derives from the view base class. The three views commonly used in Android game development are: view, Surfaceview, and Glsurfaceview.

View: Display view, built-in canvas, provides graphical drawing functions, touch-screen events, key event functions, etc. , must be updated within the UI main thread, slower.

Surfaceview: Views based on the view of the expansion of the class, more suitable for 2D game development; is a subclass of view, similar to the use of double-slow mechanism to update the screen in a new thread so the refresh interface faster than the view.

Glsurfaceview: The view class, which is extended again based on the Surfaceview view, is designed for 3D game development, and is a subclass of Surfaceview, dedicated to OpenGL.

In the development of 2D game, it can be divided into two kinds of game frame, view and Surfaceview. View and Surfaceview differences:

View: The screen must be updated in the main thread of the UI for the passive update screen.

Both the Surfaceview:ui thread and the child thread are available. Redraw the screen in a newly started thread and actively update the screen.


Updating the screen in the main thread of the UI may cause problems, such as if you are updating the screen too long, then your main UI thread will be blocked by the function you are drawing. Then you will not be able to respond to keystrokes, touch screens and other messages.
When using Surfaceview because it is updating the screen in a new thread, it does not block your UI main thread. But this also brings up another problem, that is, event synchronization, which involves thread synchronization.

Therefore, based on the above, according to the characteristics of the game, generally divided into two categories.

1 Passive Update screen. Like chess, this is good with view. Because the screen update is dependent on OnTouch to update, you can use the invalidate directly. Because of this, the touch and the next touch will take longer and will not have an impact.

2 active updates. Like a man running all the time. This requires a separate thread to redraw the human state continuously, avoiding blocking the main UI thread. So obviously the view is not suitable, need surfaceview to control.

Http://www.baidu.com/link?url= Lfzyyipsqzpqbmxudvzs79gib3vkgsuuhdcniow9vvtls4y7xy-9fvvo2kovfahrhldc6lelsrbvk7a8b9fpzewcknjh7tsyhlrxilytsvi

Http://www.cnblogs.com/devinzhang/archive/2012/01/20/2328002.html

Android's View/surfaceview/glsurfaceview

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.