Пример #1
0
 /** 创建游戏窗体载体 */
 private void createScreen() {
   this.canvasImage = new LImage(width = handler.getWidth(), height = handler.getHeight(), false);
   this.gl = canvasImage.getLGraphics();
   this.currentScreen = canvasImage.getBitmap();
   if (LSystem.isLowerVer()) {
     this.surfaceHolder = getHolder();
     this.surfaceHolder.addCallback(this);
   } else {
     this.surfaceHolder = getHolder();
     int mode = 0;
     try {
       mode = 1;
       surfaceHolder.setType(android.view.SurfaceHolder.SURFACE_TYPE_HARDWARE);
     } catch (Exception e) {
       try {
         mode = 2;
         surfaceHolder.setType(android.view.SurfaceHolder.SURFACE_TYPE_GPU);
       } catch (Exception e2) {
         surfaceHolder.setType(android.view.SurfaceHolder.SURFACE_TYPE_NORMAL);
       }
     }
     switch (mode) {
       case 1:
         Log.i("Android2DView", "Hardware surface");
         break;
       case 2:
         Log.i("Android2DView", "GPU surface");
         break;
       default:
         Log.i("Android2DView", "No hardware acceleration available");
     }
     this.surfaceHolder.addCallback(this);
     this.surfaceHolder.setFormat(PixelFormat.RGB_565);
   }
   this.setClickable(false);
   this.setFocusable(true);
   this.setFocusableInTouchMode(true);
   this.setKeepScreenOn(true);
   this.setLongClickable(false);
   this.destroyDrawingCache();
   this.setDrawingCacheBackgroundColor(0);
   this.setDrawingCacheEnabled(false);
   if (LSystem.isHTC()) {
     this.setWillNotCacheDrawing(false);
     this.setWillNotDraw(false);
   } else {
     this.setWillNotCacheDrawing(true);
     this.setWillNotDraw(true);
   }
   this.requestFocus();
   this.requestFocusFromTouch();
 }