1

I have a game where enemies are spawned from a library at random. Their size and speed are set to work on specific dimensions. However, these specific standards won't work well on phones with small screens. Is there a way to change speed, size depending on a phone's dimensions?

Sam
  • 129
  • 2
  • 10
  • You can get the screen size (http://stackoverflow.com/questions/1016896/how-to-get-screen-dimensions) and then set the size, speed, etc. accordingly. You can group sizes by small, medium, large and very large. – Embattled Swag Dec 09 '13 at 20:09

2 Answers2

0

you can get Screen size with following code:

  if (android.os.Build.VERSION.SDK_INT >= 13)
  {
    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;
    int height = size.y;
   }
   else
   {
     Display display = getWindowManager().getDefaultDisplay(); 
     int width = display.getWidth();  // deprecated
     int height = display.getHeight();  // deprecated
   }

more info, and change any thing with this information

Community
  • 1
  • 1
Shayan Pourvatan
  • 11,898
  • 4
  • 42
  • 63
0

For detecting the environment, check out the System Capabilities class (screenResolution, etc) http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/Capabilities.html

and for Flash settings, stageWidth and stageHeight may help: (http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Stage.html).

However, if you're targeting both small and large screens, you may want to think about two (or more) sets of FLA files, since you can't set stage size on-the-fly, and otherwise you'd be scaling graphics, bitmaps, etc. to fit on either.

You can use Config Constants (ActionScript settings) to signal to the code which environment you're compiling.

dhc
  • 647
  • 8
  • 17