Jump to content

iPhone 4 problem, the screen gets cut off below


Riddik
 Share

Recommended Posts

Hi!

 

On iPhone 4, if you rotate the device to portrait then back to landscape, the game gets cut off below:

 

IMG_0141.PNG

 

How to fix that?

 

My code for scale:

game.scale.hasResized.add(function() { window.AutoScaler('romeocat-game', 960, 600); });game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;    game.scale.setShowAll();game.scale.setScreenSize(true);game.scale.refresh(); 

window.AutoScaler func:

window.AutoScaler = function(element, initialWidth, initialHeight, skewAllowance){    var self = this;    this.viewportWidth = 0;    this.viewportHeight = 0;    if(typeof element === "string") element = document.getElementById(element);    this.element = element;    this.gameAspect = initialWidth / initialHeight;    this.skewAllowance = skewAllowance || 0;    // Ensure our element is going to behave:    self.element.style.display = 'block';    self.element.style.margin = '0';    self.element.style.padding = '0';    if(window.innerWidth == self.viewportWidth && window.innerHeight == self.viewportHeight) return;    var w = window.innerWidth;    var h = window.innerHeight;    var windowAspect = w / h;    var targetW = 0;    var targetH = 0;    targetW = w;    targetH = h;    if(Math.abs(windowAspect - self.gameAspect) > self.skewAllowance)    {        if(windowAspect < self.gameAspect) targetH = w / self.gameAspect;        else targetW = h * self.gameAspect;    }    self.element.style.width = targetW + "px";    self.element.style.height = targetH + "px";    self.element.style.marginLeft = ((w - targetW) / 2) + "px";    self.element.style.marginTop = ((h - targetH) / 2) + "px";    self.viewportWidth = w;    self.viewportHeight = h;    };
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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