Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Scale game to different mobile devices


craidencool
 Share

Recommended Posts

18 hours ago, kikemx78 said:

Don't know if this can help....

Go check out my code on

 

www.e-sant.com/EA/fullScreen/

 

www.e-sant.com/EA/fullScreen/mobile/

 

 

sir in your boot state 

var w = screen.width;
var h = screen.height;


var gW = 0;
var gH = 0;
var mW = 0;
var mH = 0;

var displaySize = "";

if ( w <= 599 ){
  gW = 568;
  gH = 320;
  mW = 599;
  mH = 399;
  displaySize = "SM";
}

if ( w >= 600 && w < 839 ){
  gW = 736;
  gH = 414;
  mW = 839;
  mH = 560;
  displaySize = "NL";
}

if ( w >= 840 && w < 1199 ){
  gW = 960;
  gH = 541;
  mW = 1199;
  mH = 675;
  displaySize = "LG";
}


if ( w >= 1200 && w < 1921){
  gW = 1770;
  gH = 948;
  mW = 1921;
  mH = 1055;
  displaySize = "XXL";
}

if ( w == 1024 && h == 768 ){
  gW = w;
  gH = h;
  mW = w;
  mH = h;
  displaySize = "iPad";
}

 


what does this code do? thank you so much!

Link to comment
Share on other sites

var configuration = {
'canvas_width_max' : 2048,					
'canvas_width' : 1000,						
'canvas_height_max' : 2048,				
'canvas_height' : 650,						
'scale_ratio' : 1,							
'aspect_ratio' : 1,							
};

configuration.canvas_width = window.screen.availWidth * window.devicePixelRatio;
configuration.canvas_height = window.screen.availHeight * window.devicePixelRatio;
configuration.aspect_ratio = configuration.canvas_width / configuration.canvas_height;
if (configuration.aspect_ratio < 1) configuration.scale_ratio = configuration.canvas_height / configuration.canvas_height_max;
else configuration.scale_ratio = configuration.canvas_width / configuration.canvas_width_max;

game = new Phaser.Game(configuration.canvas_width, configuration.canvas_height, options.render, 'gamewindow');

this.game.scale.fullScreenScaleMode = Phaser.ScaleManager.SHOW_ALL;
this.game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
this.game.scale.refresh();

sprite.scale.set(configuration.scale_ratio);

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...