PsyOps

RatioFix

Jun 21st, 2014
286
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.             StageRatio = (float)Math.min((float)w/(float)sW,(float)h/(float)sH);
  13.            
  14.             StagePos[2] = (int)Math.floor((float)sW * StageRatio);
  15.             StagePos[3] = (int)Math.floor((float)sH * StageRatio);
  16.             StagePos[0] = 0;
  17.             StagePos[1] = (h - StagePos[3])/2;
  18.             coordOffset = new int[]{ (w - StagePos[2])/2, (h - StagePos[3])/2 };
  19.         }
Advertisement
Add Comment
Please, Sign In to add comment