Android Open Source - fireflies_android State Controller






From Project

Back to project page fireflies_android.

License

The source code is released under:

MIT License

If you think the Android project fireflies_android 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 donothingbox.game.controller;
// ww  w  . ja  v a  2  s. c  om
import android.content.Context;
import android.graphics.Point;
import android.graphics.Rect;
import android.view.Display;
import android.view.WindowManager;

/*
 *  StateController, eventually this will manage state switching, from new activities, to states within the same activity. 
 * 
 *  Also, all scaling logic will eventually live here. 
 * 
 */

public class StateController {
  private static Context sContext;
  private static boolean DISPLAY_TRACES = true; //used for class debugging
  
  private static Rect sScreenRect;
  public static float sScaleFactor = 1.0f;

  private StateController(){}
  
  //StateController holds a static ref globally accessable
  public static void init(Context context){
    sContext = context;
  }
  
  //get the screen rectangle
  public static Rect getScreenSize(){
    if(sScreenRect == null){
      WindowManager wm = (WindowManager) sContext.getSystemService(Context.WINDOW_SERVICE);
      Display display = wm.getDefaultDisplay();
      
      Rect returnRect = new Rect();
      //depricated, but use prior to API Level 13
      
      //Point dispPoint = new Point();
      //display.getSize(dispPoint);
      //returnRect.set(0, 0, dispPoint.x, dispPoint.y);
      returnRect.set(0, 0, display.getWidth(), display.getHeight());
      StateController.classTrace("Screen Rect: " + returnRect.left + ":" + returnRect.bottom);
      sScreenRect = returnRect;
    }
    return sScreenRect;
  }
  
  //private classTrace call, to make class debugging easier
  private static void classTrace(String text){
    if(DISPLAY_TRACES)
      System.out.println(text);
  }
}




Java Source Code List

com.donothingbox.fireflies_android.CoreApp.java
com.donothingbox.fireflies_android.DynamicActivity.java
com.donothingbox.fireflies_android.GameSurfaceActivity.java
com.donothingbox.fireflies_android.MainActivity.java
donothingbox.game.controller.AudioController.java
donothingbox.game.controller.GameThread.java
donothingbox.game.controller.HUDController.java
donothingbox.game.controller.StateController.java
donothingbox.game.model.DepthSortComparator.java
donothingbox.game.utils.BitmapUtils.java
donothingbox.game.utils.Utils.java
donothingbox.game.view.CustomDrawableView.java
donothingbox.game.view.FireflySprite.java
donothingbox.game.view.GameLayout.java
donothingbox.game.view.GameSurfaceView.java
donothingbox.game.view.Sprite.java