For example, the resolution of my game is 360 x 640, the screen resolution of the phone is 1920 x 1080 or 270 x 480 (all conditionally). How can I adjust the size of my game frame to the size of the screen? It should be borne in mind that the canvas will draw many elements - at least 2 layers (background, game objects) and the game objects themselves (for example, up to 50 dynamic units on the screen). And also, which is very important, there will be graphic control buttons on the screen. Pseudocode thread:
class DrawThread extends Thread{ private boolean runFlag = false; private SurfaceHolder surfaceHolder; private Bitmap picture1; private Bitmap picture2; private Bitmap picture3; // и тд private long prevTime; public DrawThread(SurfaceHolder surfaceHolder, Resources resources){ this.surfaceHolder = surfaceHolder; picture1,2,3,4 и тд = //получаем изображения prevTime = System.currentTimeMillis(); } public void setRunning(boolean run) { runFlag = run; } @Override public void run() { Canvas canvas; while (runFlag) { long now = System.currentTimeMillis(); long elapsedTime = now - prevTime; updatePhys(); //все расчеты проводим независимо от отрисовки canvas = null; try { canvas = surfaceHolder.lockCanvas(null); synchronized (surfaceHolder) { updateScreen(); //отрисовка всех элементов на экране } } finally { if (canvas != null) { surfaceHolder.unlockCanvasAndPost(canvas); } } } } public void updatePhys(){ //расчеты } public void updateScreen(){ canvas.drawBitmap(...) canvas.drawBitmap(...) // и тд ... } }