@nanotoolkit/create-game 0.1.22 → 0.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nanotoolkit/create-game",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "private": false,
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -16,7 +16,7 @@
16
16
  "node": ">=18"
17
17
  },
18
18
  "pinnedVersions": {
19
- "@nanotoolkit/game-sdk": "0.1.15",
19
+ "@nanotoolkit/game-sdk": "0.1.16",
20
20
  "@nanotoolkit/game-cli": "0.1.10"
21
21
  },
22
22
  "publishConfig": {
Binary file
@@ -1,5 +1,5 @@
1
1
  import Phaser from 'phaser';
2
- import { ready, on, getUI } from '@nanotoolkit/game-sdk';
2
+ import { ready, on, getUI, setContentSize } from '@nanotoolkit/game-sdk';
3
3
 
4
4
  const BUNDLE_ID = '__BUNDLE_ID__';
5
5
 
@@ -8,15 +8,15 @@ const H = 1280;
8
8
 
9
9
  class MainScene extends Phaser.Scene {
10
10
  create() {
11
- this.add
12
- .text(W / 2, H / 2, '__TITLE__', {
11
+ const title = this.add
12
+ .text(0, 0, '__TITLE__', {
13
13
  fontFamily: 'sans-serif',
14
14
  fontSize: '48px',
15
15
  color: '#f5f0e6',
16
16
  })
17
17
  .setOrigin(0.5);
18
18
 
19
- ready(BUNDLE_ID, {desktop: {preferredAspectRatio: 16 / 9}}, (init) => {
19
+ ready(BUNDLE_ID, (init) => {
20
20
  this.platformInit = init;
21
21
  });
22
22
 
@@ -25,6 +25,16 @@ class MainScene extends Phaser.Scene {
25
25
  this.layoutAdvice = this.platformUI?.layout ?? null;
26
26
  this.screenLevel = this.platformUI?.screenLevel ?? null;
27
27
  this.useLargeLayout = this.screenLevel === 'Large';
28
+ const width = this.useLargeLayout ? 1280 : W;
29
+ const height = this.useLargeLayout ? 720 : H;
30
+ this.scale.setGameSize(width, height);
31
+ title.setPosition(width / 2, height / 2);
32
+ const content = this.platformUI?.displayMode === 'content';
33
+ document.body.style.touchAction = content ? 'pan-y' : 'none';
34
+ this.game.canvas.style.touchAction = content ? 'pan-y' : 'none';
35
+ if (this.input.manager.touch) this.input.manager.touch.capture = !content;
36
+ if (this.platformUI?.displayMode === 'content' && this.platformUI.viewport)
37
+ setContentSize({width: this.platformUI.viewport.width, height: this.platformUI.viewport.width * height / width});
28
38
  };
29
39
  syncUI();
30
40
  const stopUI = on('ui', syncUI);