Android Open Source - lamp-game Game Activity






From Project

Back to project page lamp-game.

License

The source code is released under:

GNU General Public License

If you think the Android project lamp-game 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.lifestudio;
/*  www.j  a v a  2 s .  co m*/
import org.andengine.engine.Engine;
import org.andengine.engine.LimitedFPSEngine;
import org.andengine.engine.camera.BoundCamera;
import org.andengine.engine.camera.Camera;
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.resolutionpolicy.RatioResolutionPolicy;
import org.andengine.entity.scene.Scene;
import org.andengine.ui.activity.BaseGameActivity;

import android.view.KeyEvent;

import com.lifestudio.manager.ResourcesManager;
import com.lifestudio.manager.SceneManager;


public class GameActivity extends BaseGameActivity {

  private BoundCamera camera;
  //private ResourcesManager resourcesManager;
  
  
  @Override
  public Engine onCreateEngine(EngineOptions pEngineOptions) 
  {
      return new LimitedFPSEngine(pEngineOptions, 60);
  }
  
  @Override
  public EngineOptions onCreateEngineOptions() {
    // Bound camera so we can set boundaries for example, the camera will
    // not follow the player after his death or falling down. Will stop
    // on 0 coordinate.
    camera = new BoundCamera(0,0,1280,800);
    EngineOptions engineOptions = new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new RatioResolutionPolicy(1280,800), this.camera);
    engineOptions.getAudioOptions().setNeedsMusic(true).setNeedsMusic(true);
    
    return engineOptions;
  }

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

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

  @Override
  public void onPopulateScene(Scene pScene,
      OnPopulateSceneCallback pOnPopulateSceneCallback) {
    
    mEngine.registerUpdateHandler(new TimerHandler(5.0f, new ITimerCallback() 
      {
              public void onTimePassed(final TimerHandler pTimerHandler) 
              {
                  mEngine.unregisterUpdateHandler(pTimerHandler);
                  SceneManager.getInstance().createMenuScene();
              }
      }));
      pOnPopulateSceneCallback.onPopulateSceneFinished();
  }

  @Override
  protected void onDestroy() {
    super.onDestroy();
    System.exit(RESULT_OK);
  }
  
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
      SceneManager.getInstance().getCurrentScene().onBackKeyPressed();
    }
    return false;
  }

}




Java Source Code List

com.lifestudio.GameActivity.java
com.lifestudio.base.BaseScene.java
com.lifestudio.extras.LevelCompleteWindow.java
com.lifestudio.manager.ResourcesManager.java
com.lifestudio.manager.SceneManager.java
com.lifestudio.object.Player.java
com.lifestudio.scene.GameScene.java
com.lifestudio.scene.LoadingScene.java
com.lifestudio.scene.MainMenuScene.java
com.lifestudio.scene.SplashScene.java