Exemplo n.º 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();
 }
Exemplo n.º 2
0
 public void destroyView() {
   try {
     synchronized (this) {
       handler.getAssetsSound().stopSoundAll();
       handler.getPlaySound().stopSoundAll();
       handler.destroy();
       ActionControl.getInstance().stopAll();
       LSystem.destroy();
       releaseResources();
       notifyAll();
     }
   } catch (Exception e) {
   }
 }
Exemplo n.º 3
0
 public LGameAndroid2DView(LGameAndroid2DActivity activity, boolean isLandscape, LMode mode) {
   super(activity.getApplicationContext());
   try {
     LSystem.setupHandler(activity, this, isLandscape, mode);
     this.handler = LSystem.getSystemHandler();
     this.handler.initScreen();
     this.activity = handler.getLGameActivity();
     this.setFPS(LSystem.DEFAULT_MAX_FPS);
     this.createScreen();
   } catch (Exception e) {
   }
 }
Exemplo n.º 4
0
 public final Bitmap getImage() {
   if (handler != null
       && !LSystem.AUTO_REPAINT
       && handler.getRepaintMode() == Screen.SCREEN_NOT_REPAINT) {
     return currentScreen;
   } else {
     if (mainLoop != null) {
       mainLoop.updateCapture(currentScreen);
     }
     return currentScreen;
   }
 }