Skip to content

Commit

Permalink
Add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
rexrainbow committed Oct 5, 2024
1 parent e48806b commit 49a1d29
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/scale-manager/resolution.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set main=./examples/scale-manager/resolution.js
cd ..
cd ..
npm run watch
46 changes: 46 additions & 0 deletions examples/scale-manager/resolution.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import phaser from 'phaser/src/phaser.js';

class Demo extends Phaser.Scene {
constructor() {
super({
key: 'examples'
})
}

preload() {
}

create() {
var print = this.add.text(0, 0, '');

var displaySize = this.scale.displaySize;
var baseSize = this.scale.baseSize;
var resolution = Math.max(displaySize.width / baseSize.width, 1);
print.text = resolution

var txt0 = this.add.text(130, 150, 'Hello xy world');
var txt1 = this.add.text(130, 170, 'Hello xy world').setResolution(resolution);

this.scale.on('resize', function (gameSize, baseSize, displaySize, previousWidth, previousHeight) {
var resolution = Math.max(displaySize.width / baseSize.width, 1);
txt1.setResolution(resolution);
print.text = resolution
}, this);
}

update() { }
}

var config = {
type: Phaser.AUTO,
parent: 'phaser-example',
width: 400,
height: 300,
scale: {
mode: Phaser.Scale.FIT,
autoCenter: Phaser.Scale.CENTER_BOTH,
},
scene: Demo
};

var game = new Phaser.Game(config);

0 comments on commit 49a1d29

Please sign in to comment.