next2d-development-mcp 1.1.7 → 1.2.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.
@@ -1286,6 +1286,94 @@ export class TopBtnMolecule extends ButtonAtom {
1286
1286
  }
1287
1287
  ```
1288
1288
 
1289
+ ### DisplayObject の中心点基準配置(scale・rotation アニメーション必須)
1290
+
1291
+ `scaleX` / `scaleY` / `rotation` を変更すると `width` / `height` の値が変わる。
1292
+ **addChild より前にスケール・回転を確定させないと、オフセット計算がずれる。**
1293
+
1294
+ 実装手順(順序厳守):
1295
+
1296
+ ```typescript
1297
+ // ステップ a: scaleX / scaleY / rotation を先に設定(width/height を確定させる)
1298
+ child.scaleX = 2;
1299
+ child.scaleY = 2;
1300
+ child.rotation = 45;
1301
+
1302
+ // ステップ b: 確定した width/height でオフセットを計算し、原点を中心に移動
1303
+ child.x = -child.width / 2;
1304
+ child.y = -child.height / 2;
1305
+
1306
+ // ステップ c: 親 Sprite に addChild(この時点で中心点基準の配置が完成)
1307
+ sprite.addChild(child);
1308
+ ```
1309
+
1310
+ #### Tween で中心点基準のスケールアニメーションを行う場合
1311
+
1312
+ ```typescript
1313
+ export class YourScaleAnimation
1314
+ {
1315
+ private readonly _job: Job;
1316
+
1317
+ constructor (sprite: Sprite, child: Sprite, callback?: () => void)
1318
+ {
1319
+ // ステップ a: 初期スケールを設定して width/height を確定
1320
+ child.scaleX = 0;
1321
+ child.scaleY = 0;
1322
+
1323
+ // ステップ b: 中心点オフセットを計算
1324
+ // scaleX=0 のとき width=0 になるため、最終サイズで計算する
1325
+ // → scaleX=1 にした上で取得し、その後に戻す
1326
+ child.scaleX = 1;
1327
+ child.scaleY = 1;
1328
+ child.x = -child.width / 2;
1329
+ child.y = -child.height / 2;
1330
+ child.scaleX = 0;
1331
+ child.scaleY = 0;
1332
+
1333
+ // ステップ c: addChild してから Tween を設定
1334
+ sprite.addChild(child);
1335
+
1336
+ this._job = Tween.add(child,
1337
+ { "scaleX": 0, "scaleY": 0 },
1338
+ { "scaleX": 1, "scaleY": 1 },
1339
+ 0.3, 0, Easing.outBack
1340
+ );
1341
+
1342
+ if (callback) {
1343
+ this._job.addEventListener(Event.COMPLETE, callback);
1344
+ }
1345
+ }
1346
+
1347
+ start (): void
1348
+ {
1349
+ this._job.start();
1350
+ }
1351
+ }
1352
+ ```
1353
+
1354
+ #### Anti-Patterns
1355
+
1356
+ ```typescript
1357
+ // NG: addChild 後にスケールを変更 → width/height が変わりオフセットがずれる
1358
+ sprite.addChild(child);
1359
+ child.scaleX = 2;
1360
+ child.scaleY = 2;
1361
+ child.x = -child.width / 2; // この時点の width は scaleX=2 適用後なので正しいが、
1362
+ // addChild 済みなので描画順が保証されない
1363
+
1364
+ // NG: スケール設定前にオフセットを計算 → width/height がデフォルト値のまま
1365
+ child.x = -child.width / 2; // scaleX 未設定の width で計算してしまう
1366
+ child.scaleX = 2;
1367
+ sprite.addChild(child);
1368
+
1369
+ // OK: a → b → c の順序を守る
1370
+ child.scaleX = 2; // a: スケール確定
1371
+ child.scaleY = 2;
1372
+ child.x = -child.width / 2; // b: オフセット計算
1373
+ child.y = -child.height / 2;
1374
+ sprite.addChild(child); // c: addChild
1375
+ ```
1376
+
1289
1377
  ---
1290
1378
 
1291
1379
  ## Content (Animation Tool)
@@ -579,6 +579,80 @@ displayObject.dispatchEvent(event);
579
579
  | `stopPropagation()` | 伝播を停止 |
580
580
  | `stopImmediatePropagation()` | 伝播を即座に停止 |
581
581
 
582
+ ## イベント定数の使用
583
+
584
+ イベントを `addEventListener` で登録する際は、文字列リテラルではなく必ず定数を使用する。
585
+
586
+ ```typescript
587
+ // NG: 文字列リテラル
588
+ sprite.addEventListener("pointerup", handler);
589
+
590
+ // OK: 定数を使用
591
+ sprite.addEventListener(PointerEvent.POINTER_UP, handler);
592
+ ```
593
+
594
+ **理由:** 定数を使用することで、タイプミスの防止、IDEによる補完・型チェック、リファクタリング時の安全性が得られる。
595
+
596
+ ### 全イベント定数一覧
597
+
598
+ | クラス | 定数 | 文字列値 | 説明 |
599
+ |--------|------|----------|------|
600
+ | `PointerEvent` | `POINTER_DOWN` | `"pointerdown"` | ポインター押下 |
601
+ | `PointerEvent` | `POINTER_UP` | `"pointerup"` | ポインター解放 |
602
+ | `PointerEvent` | `POINTER_MOVE` | `"pointermove"` | ポインター移動 |
603
+ | `PointerEvent` | `POINTER_OVER` | `"pointerover"` | ポインター進入 |
604
+ | `PointerEvent` | `POINTER_OUT` | `"pointerout"` | ポインター退出 |
605
+ | `PointerEvent` | `POINTER_LEAVE` | `"pointerleave"` | ポインター離脱 |
606
+ | `PointerEvent` | `POINTER_CANCEL` | `"pointercancel"` | ポインターキャンセル |
607
+ | `PointerEvent` | `DOUBLE_CLICK` | `"dblclick"` | ダブルクリック |
608
+ | `KeyboardEvent` | `KEY_DOWN` | `"keydown"` | キー押下 |
609
+ | `KeyboardEvent` | `KEY_UP` | `"keyup"` | キー解放 |
610
+ | `FocusEvent` | `FOCUS_IN` | `"focusin"` | フォーカス取得 |
611
+ | `FocusEvent` | `FOCUS_OUT` | `"focusout"` | フォーカス喪失 |
612
+ | `WheelEvent` | `WHEEL` | `"wheel"` | ホイール操作 |
613
+ | `VideoEvent` | `PLAY` | `"play"` | 再生リクエスト |
614
+ | `VideoEvent` | `PLAYING` | `"playing"` | 再生開始 |
615
+ | `VideoEvent` | `PAUSE` | `"pause"` | 一時停止 |
616
+ | `VideoEvent` | `SEEK` | `"seek"` | シーク操作 |
617
+ | `JobEvent` | `UPDATE` | `"update"` | プロパティ更新 |
618
+ | `JobEvent` | `STOP` | `"stop"` | ジョブ停止 |
619
+ | `Event` | `COMPLETE` | `"complete"` | 処理完了(Tween/Loader) |
620
+ | `Event` | `ENTER_FRAME` | `"enterframe"` | 毎フレーム |
621
+ | `Event` | `ADDED` | `"added"` | コンテナに追加 |
622
+ | `Event` | `ADDED_TO_STAGE` | `"addedtostage"` | Stageに追加 |
623
+ | `Event` | `REMOVED` | `"removed"` | コンテナから削除 |
624
+ | `Event` | `REMOVED_FROM_STAGE` | `"removedfromstage"` | Stageから削除 |
625
+ | `Event` | `IO_ERROR` | `"ioerror"` | IOエラー |
626
+ | `Event` | `HTTP_STATUS` | `"httpstatus"` | HTTPステータス受信 |
627
+
628
+ ### 使用例
629
+
630
+ ```typescript
631
+ import { PointerEvent, KeyboardEvent, Event } from "@next2d/events";
632
+
633
+ // ポインターイベント
634
+ button.addEventListener(PointerEvent.POINTER_DOWN, onPointerDown);
635
+ button.addEventListener(PointerEvent.POINTER_UP, onPointerUp);
636
+
637
+ // キーボードイベント
638
+ stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
639
+
640
+ // タイムラインイベント
641
+ movieClip.addEventListener(Event.ENTER_FRAME, onEnterFrame);
642
+ ```
643
+
644
+ ### 定数がないイベント
645
+
646
+ 一部のイベント(表示リスト、タイムライン、ロード関連など)は `Event` クラスの文字列リテラルを使用する。これらは定数として提供されていない。
647
+
648
+ ```typescript
649
+ import { Event } from "@next2d/events";
650
+
651
+ // 文字列リテラルを使用(定数なし)
652
+ sprite.addEventListener(Event.ADDED_TO_STAGE, onAdded);
653
+ movieClip.addEventListener(Event.ENTER_FRAME, onFrame);
654
+ ```
655
+
582
656
  ## 標準イベントタイプ
583
657
 
584
658
  ### 表示リスト関連
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "next2d-development-mcp",
3
3
  "displayName": "Next2D Development MCP",
4
- "version": "1.1.7",
4
+ "version": "1.2.0",
5
5
  "description": "MCP server for Next2D application development assistance",
6
6
  "type": "module",
7
7
  "author": "Toshiyuki Ienaga <ienaga@next2d.app>",
@@ -52,16 +52,16 @@
52
52
  },
53
53
  "devDependencies": {
54
54
  "@eslint/js": "^10.0.1",
55
- "@types/node": "^25.6.2",
56
- "@types/vscode": "^1.115.0",
57
- "@typescript-eslint/eslint-plugin": "^8.59.2",
58
- "@typescript-eslint/parser": "^8.59.2",
55
+ "@types/node": "^25.9.1",
56
+ "@types/vscode": "^1.120.0",
57
+ "@typescript-eslint/eslint-plugin": "^8.60.1",
58
+ "@typescript-eslint/parser": "^8.60.1",
59
59
  "@vscode/vsce": "^3.9.1",
60
- "eslint": "^10.3.0",
60
+ "eslint": "^10.4.1",
61
61
  "eslint-plugin-unused-imports": "^4.4.1",
62
62
  "globals": "^17.6.0",
63
63
  "typescript": "^6.0.3",
64
- "vitest": "^4.1.5"
64
+ "vitest": "^4.1.8"
65
65
  },
66
66
  "engines": {
67
67
  "node": ">=22.0.0",