Maintain screen dimensions across Android devices.
in
Android Processing
•
24 days ago
Greetings!
So I am developing an application for Android and had a question pertaining to maintaining the scaling across devices.
My current approach is using the
displayWidth/Height objects and multiplying accordingly depending on my means. example,
- class TRAIN{
- ////train movements/////
- //ADD : SOUND, SMOKE, LIGHT
- float xpos, ypos; // Starting position of shape
- float xspeed = 15; // Speed of the shape
- //////////////////////////
- TRAIN(){
- xpos = displayWidth*1.92;
- ypos = displayHeight/2.3;
- }
- void display(){
- xpos = xpos - xspeed ;
- if (xpos < displayWidth-displayWidth*2.6) {
- xpos = displayWidth*1.92;
- }
- train.resize(500, 130);
- image(train,xpos--, ypos);
- g.removeCache(train);
- if(xpos <= 1800 && xpos > -200){
- player.start();
- }
- println(xpos);
- }
- }
1