Android Open Source - things-fall-down Template Scene






From Project

Back to project page things-fall-down.

License

The source code is released under:

MIT License

If you think the Android project things-fall-down 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.github.thingsfalldown.template;
//from  w ww .j  av  a 2 s . c o  m
import org.andengine.engine.Engine;
import org.andengine.engine.camera.BoundCamera;
import org.andengine.entity.scene.Scene;
import org.andengine.opengl.vbo.VertexBufferObjectManager;

import android.app.Activity;

import com.github.thingsfalldown.manager.ResourceManager;
import com.github.thingsfalldown.manager.SceneManager.SceneType;

/**
 * The TemplateScene class is the abstract class defining what all necessary
 * methods for our scenes.
 */
public abstract class TemplateScene extends Scene {
  protected Engine engine;
  protected Activity activity;
  protected ResourceManager resourceManager;
  protected VertexBufferObjectManager vbom;
  protected BoundCamera camera;
  
  protected static final int SCREEN_SIZE_X = 800;
  protected static final int SCREEN_SIZE_Y = 480;
  
  /**
   * Default constructor for our scene.
   * Sets all required fields.
   */
  public TemplateScene() {
    this.resourceManager = ResourceManager.getInstance();
    this.engine = resourceManager.engine;
    this.activity = resourceManager.activity;
    this.vbom = resourceManager.vbom;
    this.camera = resourceManager.camera;
    createScene();
  }
  
  /**
   * Do everything we need to set our scene up in this method.
   */
  public abstract void createScene();
  
  /**
   * Define how to react when the back key is pressed.
   * For example, going to a different screen or exiting the game.
   */
  public abstract void onBackKeyPressed();
  
  /**
   * @return the scene type, such as menu or game.
   */
  public abstract SceneType getSceneType();
  
  /**
   * Handle destroying our resources when we're done with them.
   */
  public abstract void disposeScene();
}




Java Source Code List

com.github.thingsfalldown.ThingsFallDownActivity.java
com.github.thingsfalldown.manager.ResourceManager.java
com.github.thingsfalldown.manager.SceneManager.java
com.github.thingsfalldown.scene.GameScene.java
com.github.thingsfalldown.scene.LoadingScene.java
com.github.thingsfalldown.scene.LogoScene.java
com.github.thingsfalldown.scene.MainMenuScene.java
com.github.thingsfalldown.template.TemplateScene.java