soupdawgie Posted March 23, 2018 Share Posted March 23, 2018 Hi there. Does anyone had a pleasure to build a Facebook Instant Game? I've spent two days trying to scale my Phaser game in the Facebook for Android. Currently scaling works nicely on desktop, in a responsive viewport of the dev console, in the mobile Chrome -- namely everywhere, except the Facebook app. Seems like it just ignores my settings, sprites are displayed at full width, despite the canvas (and game) dimensions are correct. Here are my init and boot scripts, the scaling logic is copypasted from a random gist: // init code FBInstant.initializeAsync().then(function() { FBInstant.setLoadingProgress(50); FBInstant.setLoadingProgress(100); FBInstant.startGameAsync().then(function() { /** Config part */ var FIXED_SIZE = 720; var FIXED_MEASURE = 'Width'; /** Name mapping */ var fixedName = FIXED_MEASURE; var resName = fixedName === 'Height' ? 'Width' : 'Height'; var FIXED_NAME = fixedName.toUpperCase(); var RES_NAME = resName.toUpperCase(); /** Measures of document */ var documentElement = document.documentElement; var documentFixed = window['inner' + fixedName]; var documentRes = window['inner' + resName]; var ratio = documentRes / documentFixed; /** Canvas measures */ var canvasFixed = FIXED_SIZE; var canvasRes = FIXED_SIZE * ratio; var screen = {}; screen['CANVAS_' + FIXED_NAME] = canvasFixed; screen['CANVAS_' + RES_NAME] = canvasRes; console.log(screen.CANVAS_WIDTH); console.log(screen.CANVAS_HEIGHT); game = new Phaser.Game(screen.CANVAS_WIDTH, screen.CANVAS_HEIGHT, Phaser.CANVAS); game.state.add('Boot', Boot); game.state.add('Preload', Preload); game.state.add('GameTitle', GameTitle); game.state.add('Main', Main); game.state.add('GameOver', GameOver); //Start the first state game.state.start('Boot'); }); }); // boot code var Boot = function(game) {}; Boot.prototype = { preload: function() { }, create: function() { this.scale.scaleMode = Phaser.ScaleManager.EXACT_FIT; this.scale.pageAlignHorizontally = true; this.scale.pageAlignVertically = true; this.game.scale.refresh(); this.game.state.start("Preload"); } } Would appreciate any help! Link to comment Share on other sites More sharing options...
coder_for_life22 Posted March 27, 2018 Share Posted March 27, 2018 Hmm. Not sure what the issue is but this is how I do mine and works well for instant games. //Resolution I use Tanx.game = new Phaser.Game(640, 960, Phaser.CANVAS); //Scale mode I use this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; Link to comment Share on other sites More sharing options...
sathyaraj Posted May 16, 2018 Share Posted May 16, 2018 Is there an alternative for Phaser.ScaleManager in Phaser 3? I am trying to achieve the same with Phaser 3 and Facebook instant games Link to comment Share on other sites More sharing options...
matias_ini Posted May 22, 2018 Share Posted May 22, 2018 You can do it very easy in this way: game = new Phaser.Game ('100%', '100%', Phaser.CANVAS); Then you can get the real width and height reading game.width and game.height sathyaraj 1 Link to comment Share on other sites More sharing options...
Recommended Posts