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 7983577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:00:03+00:00 2026-06-04T11:00:03+00:00

Based on what I had read when I started working on the game that

  • 0

Based on what I had read when I started working on the game that I am currently developing I came to the conclusion that openGL on android was only good if I was doing stuff in 3D. I also came to the conclusion that a canvas on a surfaceView was the best way to build a 2D game.

In that vein of thought I programmed a custom image class that in theory would scale every loaded image based on the ratio of my development phone’s screen to the destination phone. This scaleX and scaleY idea is consistent throughout the entire game. Every point, image, speed, etc. is multiplied by the scale factor.

When I deploy the game to another device it just force closes every time. Somewhere in the massive web of code my custom autoscaleing system went wrong. In recent reading I’ve decided to adjust everything and go with OpenGL. That is where my question comes in.

Is there a way to make the game think it is played in the native resolution, IE easily convert all of the input coordinates to the coordinate that they would represent on my phone’s screen. Essentially I want to simulate a 540 x 960 screen, take a picture of that, and then display that picture scaled appropriately on the user’s screen.

How would I go about making a canvas that I drew everything to in absolute coordinates, then taking a picture of that canvas in a 540 x 960 region so that I could draw the picture of the first canvas to the canvas that is displayed to the user?

EDIT:

I would ultimately like to:
1. Create an image/canvas/thing that is the native resolution of my game.
2. Draw everything to said image, creating the current game state at the native resolution.
3. Take that image and scale it to the devices screen size
4. Display the game board to the users.

For touch input I would simply grab the coordinate the user is touching, and multiply it by a scale factor (ratio of native width to present width and the same for the y with height)

This allows me to make simple changes to keep the game functioning without recoding the entire thing. If this will give me a drop in performance, I probably need to use OpenGL, otherwise I will stick with that system.

My plan was to do something like this:

Canvas canvas = new Canvas(bitmap);

Where bitmap is an image the size of the native screen, then use all of my existing code.

EDI2:

To scale with a matrix, would I do something like this:

Canvas canvas; 
Matrix matrix = new Matrix();
matrix.postScale(screenWidth/stockWidth, screenHeight/stockHeight);
canvas.setMatrix(matrix);

....

Game Loop Logic with no image scaling, just drawing and updating of canvas based on   
stock size.

Is that correct?

  • 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-04T11:00:05+00:00Added an answer on June 4, 2026 at 11:00 am

    You could use the setMatrix method on Canvas, calculate the scaling needed once, and in your code use a fixed coordinate system.

    As for openGL for 2D, it works much faster than Canvas, and has a larger memory buffer for bitmaps. Canvas works well for small games, but not intensive ones.

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

Sidebar

Related Questions

I am working on a 3d tile-based strategy game and have read that implementing
I had a Java program that I run thousand times based on a loop
Somehow I had the impression that ASP.Net differentiates URLs based on the number of
We're starting to standardise on a Ruby-based testing framework, having had some very good
I'm thinking of writing a new web-based game, and wondered if anyone had any
I'm working on an application that will read in file paths and play audio
Today I've had a read about wordpress plugins, so far I understand that they
I am working on a program that encodes a file based on a supplied
I am working on some stuff that should be able to read PDF in
I had a Navigation Controller based application and decided to use tab bars. And

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.