Riddik Posted September 11, 2014 Share Posted September 11, 2014 Hi! On iPhone 4, if you rotate the device to portrait then back to landscape, the game gets cut off below: 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 More sharing options...
megan Posted September 11, 2014 Share Posted September 11, 2014 I think it's a bug with iOS 4 Safari. You can read about how other people have been working around it here: http://stackoverflow.com/questions/2581957/iphone-safari-does-not-auto-scale-back-down-on-portrait-landscape-portrait?rq=1 Riddik 1 Link to comment Share on other sites More sharing options...
Riddik Posted September 12, 2014 Author Share Posted September 12, 2014 @megan, thanks. Link to comment Share on other sites More sharing options...
Recommended Posts