This article briefly discusses the architecture of future Android game engine templates. In the Android game development Tutorial II: The View class and the Surfaceview class we've talked about, Surfaceview class has a lot of advantages, so in the Android game development or choose Surfaceview.
Here we inherit Surfaceview directly, implement Surfaceholder.callback interface, deal with surfacecreated, surfacechanged and Surfacedestroyed methods, Here we do not have the key to control the incoming, the final game control aspects of the view is still the internal class processing is better, For specific Surfaceview, we can see the control implementation of camera in the Android Open source project on screen capture and videoview you can clearly understand the ultimate intention.
Java code
public class Cwjview extends Surfaceview implements Surfaceholder.callback {public
Cwjview AttributeSet attrs) {
Super (context, attrs);
Surfaceholder Holder=getholder ();
Holder.addcallback (this);
Setfocusable (true);
public void surfacechanged (surfaceholder holder, int format, int width, int height) {
} public
void surfacecreated (Surfaceholder Holder) {
} public
void Surfacedestroyed (Surfaceholder holder) {
}
@Override public
Void Onwindowfocuschanged (Boolean haswindowfocus) {
}
The above is to the Android Surfaceview data collation, follow-up continue to supplement the relevant information, thank you for your support of this site!