-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e48806b
commit 49a1d29
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |