create-pixifact 0.11.2 → 0.13.0

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/README.md CHANGED
@@ -17,15 +17,19 @@ bun run dev
17
17
  - 一个最小 Pixifact Scene 资产对
18
18
  - Vite 项目脚本
19
19
  - `pixifact` 和 `pixifact-cli` 依赖
20
+ - 开发模式下的 Pixifact Runtime 接入,可直接观察节点、截图、菜单状态并模拟输入
20
21
 
21
22
  ## 生成脚本
22
23
 
23
24
  ```bash
24
- bun run compile:scenes
25
25
  bun run dev
26
- bun run build
26
+ pixifact runtime tree
27
+ pixifact runtime state
28
+ pixifact runtime screenshot
27
29
  ```
28
30
 
31
+ 先在浏览器打开开发页面,再运行 Runtime 命令。可从 `runtime tree` 找到 `startButtonBack` 的 Pixi `uid`,用 `runtime node <uid>` 查看其 `globalBounds`,再按中心点执行 `runtime input click --x <x> --y <y>`。`runtime state` 初始返回 `startPressed: false`,点击后返回 `true`。扩展游戏时,在 Scene 或游戏逻辑中维护明确的业务状态,并由 `registerPixiRuntime` 的 `getState` 返回。
32
+
29
33
  ## 环境要求
30
34
 
31
35
  - Bun
@@ -1,7 +1,6 @@
1
1
  import { cp, mkdir, readdir, readFile, stat, writeFile } from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { fileURLToPath } from 'node:url';
4
- const defaultPort = 5177;
5
4
  function packageDirectory() {
6
5
  const currentFile = fileURLToPath(import.meta.url);
7
6
  const sourceDirectory = path.basename(path.dirname(currentFile));
@@ -53,12 +52,6 @@ export async function createPixifactProject(options) {
53
52
  const projectJsonPath = path.join(projectRoot, 'pixifact.project.json');
54
53
  const projectJson = JSON.parse(await readFile(projectJsonPath, 'utf8'));
55
54
  projectJson.name = projectDisplayName(options.name);
56
- projectJson.run = {
57
- command: 'bun',
58
- args: ['run', 'dev'],
59
- cwd: '.',
60
- url: `http://127.0.0.1:${defaultPort}`,
61
- };
62
55
  await writeJson(projectJsonPath, projectJson);
63
56
  return {
64
57
  name: options.name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pixifact",
3
- "version": "0.11.2",
3
+ "version": "0.13.0",
4
4
  "description": "创建 Pixifact 游戏项目。",
5
5
  "packageManager": "bun@1.3.13",
6
6
  "type": "module",
@@ -10,10 +10,10 @@
10
10
  },
11
11
  "dependencies": {
12
12
  "pixi.js": "8.18.1",
13
- "pixifact": "^0.11.2"
13
+ "pixifact": "^0.13.0"
14
14
  },
15
15
  "devDependencies": {
16
- "pixifact-cli": "^0.11.2",
16
+ "pixifact-cli": "^0.13.0",
17
17
  "typescript": "^5.3.3",
18
18
  "vite": "^8.0.10"
19
19
  }
@@ -10,11 +10,5 @@
10
10
  },
11
11
  "scenes": {
12
12
  "mainMenu": "src/scenes/MainMenu.scene"
13
- },
14
- "run": {
15
- "command": "bun",
16
- "args": ["run", "dev"],
17
- "cwd": ".",
18
- "url": "http://127.0.0.1:5177"
19
13
  }
20
14
  }
@@ -52,3 +52,8 @@ resizeViewport();
52
52
 
53
53
  const resizeObserver = new ResizeObserver(resizeViewport);
54
54
  resizeObserver.observe(gameRoot);
55
+
56
+ if (import.meta.env.DEV) {
57
+ const { registerPixiRuntime } = await import('pixifact/runtime-dev');
58
+ registerPixiRuntime(app, { getState: () => scene.snapshot() });
59
+ }
@@ -4,6 +4,8 @@ import { createEvent, event, part, scene } from 'pixifact/scene';
4
4
 
5
5
  @scene()
6
6
  export class MainMenu extends Group {
7
+ private startPressed = false;
8
+
7
9
  @part()
8
10
  protected declare startButtonBack: Graphics;
9
11
 
@@ -17,6 +19,7 @@ export class MainMenu extends Group {
17
19
  this.startButtonBack.eventMode = 'static';
18
20
  this.startButtonBack.cursor = 'pointer';
19
21
  this.startButtonBack.on('pointertap', () => {
22
+ this.startPressed = true;
20
23
  this.startLabel.text = 'READY';
21
24
  this.start.emit();
22
25
  });
@@ -27,4 +30,8 @@ export class MainMenu extends Group {
27
30
  this.startButtonBack.tint = 0xffffff;
28
31
  });
29
32
  }
33
+
34
+ snapshot() {
35
+ return { startPressed: this.startPressed };
36
+ }
30
37
  }
@@ -1,8 +1,9 @@
1
1
  import { defineConfig } from 'vite';
2
- import { pixifact } from 'pixifact/compiler-node';
2
+ import { pixifact, pixifactRuntimePlugin } from 'pixifact/compiler-node';
3
3
 
4
4
  export default defineConfig({
5
5
  plugins: [
6
6
  pixifact(),
7
+ pixifactRuntimePlugin(),
7
8
  ],
8
9
  });