Android Open Source - Gloomy-Dungeons-3D Zame Game View






From Project

Back to project page Gloomy-Dungeons-3D.

License

The source code is released under:

MIT License

If you think the Android project Gloomy-Dungeons-3D listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package zame.game.views;
/*from   w ww.  java  2 s  .co  m*/
import android.content.Context;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.MotionEvent;
import zame.game.ZameGame;

public class ZameGameView extends zame.libs.GLSurfaceView21
{
  private ZameGame game;

  public ZameGameView(Context context, AttributeSet attrs)
  {
    super(context, attrs);

    setFocusable(true);
    requestFocus();
    setFocusableInTouchMode(true);
  }

  public void setGame(ZameGame game)
  {
    this.game = game;
    setRenderer(game);
  }

  @Override
  public void onWindowFocusChanged(boolean hasWindowFocus)
  {
    if (game != null) {
      if (hasWindowFocus) {
        game.resume();
      } else {
        game.pause();
      }
    }
  }

  public static boolean canUseKey(int keyCode)
  {
    return (
      (keyCode != KeyEvent.KEYCODE_BACK) &&
      (keyCode != KeyEvent.KEYCODE_HOME) &&
      (keyCode != KeyEvent.KEYCODE_MENU) &&
      (keyCode != KeyEvent.KEYCODE_ENDCALL)
    );
  }

  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event)
  {
    if (canUseKey(keyCode) && (game != null)) {
      if (game.handleKeyDown(keyCode)) {
        return true;
      }
    }

    return super.onKeyDown(keyCode, event);
  }

  @Override
  public boolean onKeyUp(int keyCode, KeyEvent event)
  {
    if (canUseKey(keyCode) && (game != null)) {
      if (game.handleKeyUp(keyCode)) {
        return true;
      }
    }

    return super.onKeyUp(keyCode, event);
  }

  @Override
  public boolean onTouchEvent(MotionEvent event)
  {
    if (game != null) {
      game.handleTouchEvent(event);
    }

    try {
      Thread.sleep(16);
    } catch (InterruptedException e) {
    }

    return true;
  }

  @Override
  public boolean onTrackballEvent(MotionEvent event)
  {
    if (game != null) {
      game.handleTrackballEvent(event);
    }

    return true;
  }
}




Java Source Code List

zame.game.AppConfig.java
zame.game.AppConfig.java
zame.game.Common.java
zame.game.ConfigZeemote.java
zame.game.ConfigZeemote.java
zame.game.Config.java
zame.game.GameActivityZeemoteHelper.java
zame.game.GameActivityZeemoteHelper.java
zame.game.GameActivity.java
zame.game.GamePreferencesActivity.java
zame.game.GamePreferencesActivity.java
zame.game.MenuActivityHelper.java
zame.game.MenuActivityHelper.java
zame.game.MenuActivity.java
zame.game.Renderer.java
zame.game.SoundManager.java
zame.game.ZameApplicationAnalyticsHelper.java
zame.game.ZameApplicationAnalyticsHelper.java
zame.game.ZameApplication.java
zame.game.ZameGame.java
zame.game.ZameJniRenderer.java
zame.game.engine.Action.java
zame.game.engine.AutoWall.java
zame.game.engine.Controls.java
zame.game.engine.Door.java
zame.game.engine.GameHelper.java
zame.game.engine.GameHelper.java
zame.game.engine.Game.java
zame.game.engine.Labels.java
zame.game.engine.LevelConfig.java
zame.game.engine.LevelRenderer.java
zame.game.engine.Level.java
zame.game.engine.Mark.java
zame.game.engine.Monster.java
zame.game.engine.Overlay.java
zame.game.engine.PortalTracer.java
zame.game.engine.State.java
zame.game.engine.Stats.java
zame.game.engine.TextureLoader.java
zame.game.engine.Weapons.java
zame.game.views.EndLevelView.java
zame.game.views.GameOverView.java
zame.game.views.GameView.java
zame.game.views.IZameView.java
zame.game.views.MenuViewHelper.java
zame.game.views.MenuViewHelper.java
zame.game.views.MenuView.java
zame.game.views.PreLevelView.java
zame.game.views.ZameGameView.java
zame.libs.FrameLayout.java
zame.libs.GLSurfaceView21.java
zame.libs.Grid.java
zame.libs.KeyMapPreference.java
zame.libs.LabelMaker.java
zame.libs.ListPreference.java
zame.libs.NumericSprite.java
zame.libs.SeekBarPreference.java
zame.promo.PromoView.java