Advertisement
NoneyaBiznazz

Setting up camera in Andengine

Apr 24th, 2013
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1.  
  2.  
  3.  
  4. public EngineOptions onCreateEngineOptions() {
  5.    
  6. this.display = getWindowManager().getDefaultDisplay();//get screen from system
  7.         this.screenwidth  = display.getWidth();
  8.         this.screenheight = display.getHeight();
  9.        
  10.  
  11. float screenratio;
  12. int screenscale = 300; /* sets height, width is derived from following equation*/
  13.  
  14. if(screenwidth>screenheight)
  15.         {
  16.             screenratio=screenwidth/screenheight;
  17.             height = screenscale;
  18.             width = (int)(screenscale*screenratio);
  19.         }
  20.         else
  21.         {
  22.             screenratio=screenheight/screenwidth;
  23.             width = screenscale;
  24.             height = (int) (screenscale*screenratio);
  25.         }
  26.  
  27.  
  28.  
  29. screenwidth = width;
  30. screenheight = height;
  31.  
  32.  
  33. this.mCamera = new SmoothCamera(0, 0, width, height, 1000, 1000, 10);//create smooth scrolling camera
  34.  
  35.  
  36. this.engineOptions = new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new RatioResolutionPolicy(screenratio), mCamera);
  37. return engineOptions;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement