I'm puzzled about the purpose of Phaser.Display.Align.In.Center
. The code snippet below is taken from an official example
class Example extends Phaser.Scene
{
constructor ()
{
super();
}
preload() {
this.load.path = 'https://raw.githubusercontent.com/photonstorm/phaser3-examples/master/public/assets/';
this.load.image('pic', 'pics/barbarian-loading.png');
}
create ()
{
const pic = this.add.image(400, 300, 'pic');
//Phaser.Display.Align.In.Center(pic, this.add.zone(400, 300, 800, 600));
}
}
var config = {
width: 800,
height: 600,
backgroundColor: '#666', //0xf3f3f3
scene: [Example]
}
var game = new Phaser.Game(config);
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1e6e767f6d7b6c5e2d302b2b302c">[email protected]</a>/dist/phaser.js"></script>
The line I have commented out is:
//Phaser.Display.Align.In.Center(pic, this.add.zone(400, 300, 800, 600));
Even without using this line, I still achieve the same result - an image centered on the screen.
Considering we already have setOrigin
, what exactly is the function of "Phaser.Display.Align.In.Center"?