Android Open Source - MoonMiner Main Activity






From Project

Back to project page MoonMiner.

License

The source code is released under:

MIT License

If you think the Android project MoonMiner 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 com.lhbdev.moonminer2;
//from w w  w  . j a  va  2 s.c o m
import java.io.IOException;

import org.andengine.engine.Engine;
import org.andengine.engine.LimitedFPSEngine;
import org.andengine.engine.camera.BoundCamera;
import org.andengine.engine.handler.timer.ITimerCallback;
import org.andengine.engine.handler.timer.TimerHandler;
import org.andengine.engine.options.EngineOptions;
import org.andengine.engine.options.ScreenOrientation;
import org.andengine.engine.options.WakeLockOptions;
import org.andengine.engine.options.resolutionpolicy.FillResolutionPolicy;
import org.andengine.entity.scene.Scene;
import org.andengine.ui.activity.BaseGameActivity;

import android.view.KeyEvent;

import com.lhbdev.moonminer.manager.ResourcesManager;
import com.lhbdev.moonminer.manager.SceneManager;

public class MainActivity extends BaseGameActivity
{
  //-------------------------------------------
  // VARIABLES
  //------------------------------------------
  private BoundCamera camera;
  private ResourcesManager resourcesManager;
  public Scene mScene;
  

  @Override
  public EngineOptions onCreateEngineOptions() 
  {
    camera = new BoundCamera(0, 0, 800, 480);
    EngineOptions engineOptions = new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new FillResolutionPolicy(), camera);
    engineOptions.getAudioOptions().setNeedsMusic(true).setNeedsSound(true);
    engineOptions.setWakeLockOptions(WakeLockOptions.SCREEN_ON);
     
    return engineOptions;
  }

  @Override
  public void onCreateResources(OnCreateResourcesCallback pOnCreateResourcesCallback)  throws IOException 
  {
     ResourcesManager.prepareManager(mEngine, this, camera, getVertexBufferObjectManager());
     resourcesManager = ResourcesManager.getInstance();
     pOnCreateResourcesCallback.onCreateResourcesFinished();
  }

  @Override
  public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback) throws IOException 
  {
     SceneManager.getInstance().createSplashScene(pOnCreateSceneCallback);
  }

  @Override
  public void onPopulateScene(Scene pScene,OnPopulateSceneCallback pOnPopulateSceneCallback) throws IOException 
  {
     mEngine.registerUpdateHandler(new TimerHandler(2f, new ITimerCallback()
     {
      public void onTimePassed(final TimerHandler pTimerHandler)
      {
        mEngine.unregisterUpdateHandler(pTimerHandler);
        //load menu resources, create menu scene
        SceneManager.getInstance().createMenuScene();
      }
     }));
     pOnPopulateSceneCallback.onPopulateSceneFinished();
  }
  
  @Override
  public Engine onCreateEngine(EngineOptions pEngineOptions)
  {
    return new LimitedFPSEngine(pEngineOptions, 60);
  }
  
  @Override
  protected void onDestroy()
  {
    super.onDestroy();
    if(this.isGameLoaded())
    {
      System.exit(0);
    }
  }
  
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event)
  {
    if(keyCode == KeyEvent.KEYCODE_BACK)
    {
      SceneManager.getInstance().getCurrentScene().onBackKeyPressed();
    }
    return false;
  }
  
  
}




Java Source Code List

com.lhbdev.moonminer2.MainActivity.java
com.lhbdev.moonminer.base.BaseScene.java
com.lhbdev.moonminer.manager.ResourcesManager.java
com.lhbdev.moonminer.manager.SceneManager.java
com.lhbdev.moonminer.object.Dpad.java
com.lhbdev.moonminer.object.Player.java
com.lhbdev.moonminer.scene.GameScene.java
com.lhbdev.moonminer.scene.LoadingScene.java
com.lhbdev.moonminer.scene.MainMenuScene.java
com.lhbdev.moonminer.scene.SplashScene.java