0
\$\begingroup\$

I’m working with Phaser Editor, and I was wondering if it was possible to resize the scene with the editor or just plain Phaser 2. I want to resize the world, by which I mean to make a camera follow the player past the screen, but I can’t figure out how in the docs for phaser 2 or phaser editor. Can someone help?

\$\endgroup\$
1
\$\begingroup\$

I haven't tested Phaser Editor to see if it's possible to resize a game but if you want to resize your game in Phaser 2 (CE) with some code it's easy, in fact you have diffrent ways of doing that in the init() method using :

game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;

You can replace SHOW_ALL and play with this command by

  • EXACT_FIT
  • RESIZE
  • SHOW_ALL

Plus other options for the command that I don't add to this list because those are the most important and you can find in the documentation

In my opinion the best one and the most used is to scale it like the code below by using Phaser.ScaleManager.SHOW_ALL

var game = new Phaser.Game({
  state: {

    init: function() {
      game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
      game.scale.pageAlignHorizontally = true;
      game.scale.pageAlignVertically = true;
    },

    preload: function() {
      // This is equivalent to <https://examples.phaser.io/assets/>.
      this.load.baseURL = 'https://raw.githubusercontent.com/photonstorm/phaser-examples/master/examples/assets/';
      this.load.crossOrigin = 'anonymous';
      this.load.image('einstein', 'pics/ra_einstein.png');
    },

    create: function() {
      this.add.image(0, 0, 'einstein');
    },

    update: function() {

    }

  }
});
html, body {
  padding: 0;
  margin: 0;
}
<script src="https://cdn.jsdelivr.net/npm/phaser-ce@2.13.1/build/phaser.js"></script>

\$\endgroup\$
0
\$\begingroup\$

I guess you are using Phaser Editor 1.5.3. You look inside the examples provided by the editor: Friend of Cuco or Sunny Land Forest. In both examples, the world is bigger than the screen and the camera follows the player. You should do that in code, using the Phaser 2 API.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.