PsyOps

ResFix

Jun 21st, 2014
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     public void adjustStagePos()
  2.     {
  3.         int sW = (int)stageBG.getWidth();
  4.         int sH = (int)stageBG.getHeight();
  5.        
  6.         // Device res is not compatible
  7.         if ( w < sW || h < sH){
  8.            
  9.         }
  10.         else{
  11.            
  12.             float ratioW = (float)Math.floor(w/sW);
  13.             float ratioH = (float)Math.floor(h/sH);
  14.            
  15.             if ( ratioW == ratioH || ratioW < ratioH){
  16.                 StageRatio = ratioW;
  17.                 StagePos[2] = w;
  18.                 StagePos[3] = (int)Math.floor((float)sH * StageRatio);
  19.                 StagePos[0] = 0;
  20.                 StagePos[1] = (h - StagePos[3])/2;
  21.                 coordOffset = new int[]{ 0, (h - StagePos[3])/2 };
  22.             }
  23.         }
Advertisement
Add Comment
Please, Sign In to add comment