/** 创建游戏窗体载体 */ 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(); }
public void destroyView() { try { synchronized (this) { handler.getAssetsSound().stopSoundAll(); handler.getPlaySound().stopSoundAll(); handler.destroy(); ActionControl.getInstance().stopAll(); LSystem.destroy(); releaseResources(); notifyAll(); } } catch (Exception e) { } }
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) { } }
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; } }