Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8971897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:04:39+00:00 2026-06-15T18:04:39+00:00

I am making a game using And Engine, when i tried to make it

  • 0

I am making a game using And Engine, when i tried to make it in generic way that works on all devices then i am in trouble…

I need to set a sprite on specific position of background sprite that should work on all screens… My background screen has same size as dimension of Device..

I tried to use pixel let say Glaxy S3 ha dimensions 720*1280

And i set according to it my sprite at location (584,608)

and my HTC experia ha dimensions (320,480)

SO i need to set it on (244,172) ….

I have tried all the following ways to set the position of sprites in generic way but not if any work…

I have tried alot of following things to make some formula that enables me to do it but unable to find any.. please advise

final Display display = getWindowManager().getDefaultDisplay();
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);

 metrics.density;
 metrics.densityDpi;
 metrics.heightPixels);
 metrics.scaledDensity);
 metrics.widthPixels);
 metrics.xdpi);
 metrics.ydpi);



Point point = getDisplaySize(display);
 CAMERA_WIDTH = point.x;
 CAMERA_HEIGHT = point.y;
 DisplayMetrics dm = new DisplayMetrics();     getWindowManager().getDefaultDisplay().getMetrics(dm);
 double x = Math.pow(dm.widthPixels/dm.xdpi,2); 
 double y = Math.pow(dm.heightPixels/dm.ydpi,2);
 double screenInches = Math.sqrt(x+y);
 int widthPix = (int) Math.ceil(dm.widthPixels * (dm.densityDpi / 160.0));

//CAMERA_WIDTH = display.getWidth();
//CAMERA_HEIGHT = display.getHeight();

Problem is little bit complex.. As i told above I tried to use pixel let say Glaxy S3 ha *dimensions 720*1280 And required sprite location is (584,608)
so i set in manner ( CAMERA_WIDTH/1.233f,CAMERA_HEIGHT/2.112f)*

BUT HTC experia has dimensions *320*480 So the required positions according to ( CAMERA_WIDTH/1.233f,CAMERA_HEIGHT/2.112f) is (2599.5,227.27)*
but this wrong according to display…
when i set it on (244,172) for experia its working perfect.… please help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T18:04:41+00:00Added an answer on June 15, 2026 at 6:04 pm

    AndEngine offers multiple resolution policies. They are used to determine the size of the RenderSurfaceView, thus the actual size of the game on the screen, depending on the screen size.

    You should use RatioResolutionPolicy: It will use the largest possible size, while keeping a constant ratio between the width and the height. By keeping the camera’s size constant, everything it shows will be scaled by this constant ratio which will vary on different devices.

    Example: Let CAMERA_WIDTH = 720 and CAMERA_HEIGHT = 480. If we create the camera and the engine options this way:

    this.mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
    EngineOptions options = new EngineOptions(..., new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), mCamera);
    

    The ratio is 720 / 480 = 1.5.
    When placing a sprite on your scene, use constant coordinates. Let’s say we place it in the middle of the screen:

    Sprite sprite = new Sprite(CAMERA_WIDTH / 2, CAMERA_HEIGHT / 2, ...);
    

    So:

    • On a device with screen size 720×480, the sprite will be placed at (360, 240) screen coordinates.
    • On a device with screen size 480×320, the sprite will be placed at (240, 160) screen coordinates.
    • On a device with screen size 800×480, the sprite will be placed at (400, 240) screen coordinates.

    And so on…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making a game engine using HTML5 canvas, and I have decided to
I am making a 2D game in javascript/ajax, that will be using data stored
Context I'm making a game engine using SDL and OpenGL. I'm trying to find
okay i'm making a game using c++ (for the engine) and openGL, now i've
I'm making a game engine in C++. It is supposed to read all its
I am making game for android using libgdx my requirement is that when character
I've been making a game using the rokonandroid game engine, but I randomly get
Im making a game and using surfaceview. I load bitmaps that represent character and
I'm making my first game using Java on Android. I need to draw a
I'm making a iPhone App written in Objective-C using the Cocos2d game engine. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.