Kalwang / beginning-android-games

Automatically exported from code.google.com/p/beginning-android-games
0 stars 0 forks source link

Display type deprecated #73

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The method getHeight() from the type Display is deprecated  
The method getWidth() from the type Display is deprecated

What version of the product are you using? On what operating system?
Build: v22.0.1-685705 (ADT version)
compiler API 16: 4.1(jellybean)
OS: windows XP SP3

Please provide any additional information below.

float 
scaleX=(float)frameBufferWidth/getWindowManager().getDefaultDisplay().getWidth()
;

&

float 
scaleY=(float)frameBufferHeight/getWindowManager().getDefaultDisplay().getHeight
();

In these two lines in AndroidGame class i am getting getWidth and get Height 
part striked out.
It says deprecated.
Can Anybody help me out with the issue? 

Original issue reported on code.google.com by royatwor...@gmail.com on 22 Jun 2013 at 12:19

GoogleCodeExporter commented 9 years ago
Use this:

DisplayMetrics displaymetrics = new DisplayMetrics();
mContext.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
int screenWidth = displaymetrics.widthPixels;
int screenHeight = displaymetrics.heightPixels;

Original comment by zhuin...@gmail.com on 3 Apr 2015 at 7:26