Hello guys, i have a big problem. I am almost ready to publish my first game in google play, but i cannot figure out how to make the app compatible with all the different sizes of screens (1280x720, 1920x1080 etc.) . Here is a simple examble of what i am trying to do:
So, the “if” represents a red button that is going to start the game. I started the game with a 1280x720 scren, but i remembered that i want to make the app compatible with all devices, so:
So i found how many % of 1280 is 140 and replaced it with “if(…&& mouseX > width - 89/100 * width…” and i did the same thing (with different percentages of course) with all the mouseY and mouseX’s, but it didn’t work… I really don’t know what to do, please help me! Thanks!
So, when i do that, it tells me my value for mouseX is 1920, but when i post the same calculation in google, it tells me that its 140. I don’t know why.
Look into integer division. Basically, an int value can only hold whole numbers, without any decimal places. Since 70 and 100 are both int values, the result is an int as well. And since it can’t hold a decimal place, it ends up being 0 instead of 0.7.
Try it out with a simpler example:
int x = 70;
int y = 100;
int z = x / y;
println(z);