I use canvas.scale to optimize the playing field in my game, but I ran into a problem - canvas.scale (x, y) x and y = 0, so nothing is displayed on the screen, although the logic should have a value with a dot. How can I solve this problem?

Here is the code: `public class Game extends Activity {

public static int heightDisplay; public static int widthDisplay; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new GamePanel(this)); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); DisplayMetrics displaymetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); heightDisplay = displaymetrics.heightPixels; widthDisplay = displaymetrics.widthPixels; } 

} `

 public static final int WIDTH = 720; public static final int HEIGHT = 1280; @Override public void draw(Canvas canvas) { if(canvas!=null) { final int savedState = canvas.save(); canvas.scale(Game.widthDisplay/WIDTH, Game.heightDisplay/HEIGHT); bg.draw(canvas); canvas.restoreToCount(savedState); } } 

}

    1 answer 1

    The point is infinitely small, that's not displayed)

    • How is it infinitely small? If you carry out these same actions through a calculator, it shows reasonable numbers (0.8, 0.8, etc.) - En1q0d
    • you yourself wrote that x и y = 0 - xkor
    • Yes, I output through logs, and there everything is by zeros, although there cannot be zero in any way - En1q0d
    • Well, if I really could not, I would not have turned out. So look for a mistake there. - xkor 5:26 pm