Android Open Source - androidtbsgame Main Activity






From Project

Back to project page androidtbsgame.

License

The source code is released under:

MIT License

If you think the Android project androidtbsgame 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 de.mmssb.androidtbsgame.andengine;
/* w w  w  .j av  a  2 s . c  om*/
import org.andengine.engine.camera.SmoothCamera;
import org.andengine.engine.options.EngineOptions;
import org.andengine.engine.options.ScreenOrientation;
import org.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.util.FPSLogger;
import org.andengine.ui.activity.SimpleBaseGameActivity;

import android.util.DisplayMetrics;
import de.mmssb.androidtbsgame.andengine.hud.ModelHUD;
import de.mmssb.androidtbsgame.andengine.managers.SceneManager.SceneType;

/**
 * @author Manu
 * 
 */
public class MainActivity extends SimpleBaseGameActivity {
  private Model model;
  private SmoothCamera camera;

  @Override
  public EngineOptions onCreateEngineOptions() {
    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int deviceWidth = metrics.heightPixels;
    int deviceHeight = metrics.widthPixels;
    camera = new SmoothCamera(0, 0, deviceHeight, deviceWidth,
        deviceWidth / 2, deviceWidth / 2, 1);
    camera.setBoundsEnabled(true);
    return new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED,
        new RatioResolutionPolicy(deviceHeight, deviceWidth), camera);
  }

  @Override
  protected void onCreateResources() {
    model = new Model(this);
    camera.setHUD(new ModelHUD(model));
    model.getSceneManager().setActualSceneType(SceneType.GAME);
  }

  @Override
  protected Scene onCreateScene() {
    this.mEngine.registerUpdateHandler(new FPSLogger());
    return model.getSceneManager().getActualScene();
  }

  public SmoothCamera getSmoothCamera() {
    return camera;
  }
}




Java Source Code List

de.mmssb.androidtbsgame.andengine.BoardMap.java
de.mmssb.androidtbsgame.andengine.GameControl.java
de.mmssb.androidtbsgame.andengine.MainActivity.java
de.mmssb.androidtbsgame.andengine.Model.java
de.mmssb.androidtbsgame.andengine.entities.board.Board.java
de.mmssb.androidtbsgame.andengine.entities.board.Cell.java
de.mmssb.androidtbsgame.andengine.entities.board.Mark.java
de.mmssb.androidtbsgame.andengine.hud.ImageButtonSprite.java
de.mmssb.androidtbsgame.andengine.hud.ModelHUD.java
de.mmssb.androidtbsgame.andengine.managers.CellControl.java
de.mmssb.androidtbsgame.andengine.managers.Manager.java
de.mmssb.androidtbsgame.andengine.managers.ResourceManager.java
de.mmssb.androidtbsgame.andengine.managers.SceneManager.java
de.mmssb.androidtbsgame.andengine.managers.SharedPreferencesManager.java
de.mmssb.androidtbsgame.andengine.scenes.GameScene.java
de.mmssb.androidtbsgame.andengine.scenes.ModelScene.java
de.mmssb.androidtbsgame.andengine.units.AnimationProperties.java