next2d-development-mcp 1.1.8 → 1.3.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)
|
|
@@ -241,6 +241,7 @@ DisplayObjectは、Next2D Playerにおける全ての表示オブジェクトの
|
|
|
241
241
|
| `mouseX` | number | 対象のDisplayObjectの基準点からのマウスのX座標(ピクセル) |
|
|
242
242
|
| `mouseY` | number | 対象のDisplayObjectの基準点からのマウスのY座標(ピクセル) |
|
|
243
243
|
| `root` | MovieClip \| Sprite \| null | DisplayObjectのルートであるDisplayObjectContainer |
|
|
244
|
+
| `namespace` | string | クラスの空間名(例: `"next2d.display.Sprite"`)を返却。クラス判定に使用する(詳細は[クラス判定](#クラス判定namespace)を参照) |
|
|
244
245
|
|
|
245
246
|
### 読み書きプロパティ
|
|
246
247
|
|
|
@@ -480,6 +481,45 @@ sprite.cacheAsBitmap = null;
|
|
|
480
481
|
- `stage.rendererScale`が変更されるとキャッシュが自動的に無効化されます
|
|
481
482
|
- `filter`と`cacheAsBitmap`を同時に設定した場合、`cacheAsBitmap`が優先されます
|
|
482
483
|
|
|
484
|
+
## クラス判定(namespace)
|
|
485
|
+
|
|
486
|
+
クラスの種類を判定する際に `constructor.name` を使用してはいけません。プロダクションビルドでは minify によってクラス名が短縮・変更されるため、開発環境では動作してもビルド後に判定が壊れます。
|
|
487
|
+
|
|
488
|
+
代わりに `namespace` プロパティを使用します。`namespace` はハードコードされた文字列(例: `"next2d.display.Stage"`)を返すため、minify の影響を受けません。インスタンスの getter と static getter の両方が用意されています。
|
|
489
|
+
|
|
490
|
+
```typescript
|
|
491
|
+
const { Stage, Sprite } = next2d.display;
|
|
492
|
+
|
|
493
|
+
// ❌ NG: minify でクラス名が変わるため、ビルド後に判定が壊れる
|
|
494
|
+
if (displayObject.constructor.name === "Stage") { /* ... */ }
|
|
495
|
+
|
|
496
|
+
// ✅ OK: インスタンスの namespace で判定
|
|
497
|
+
if (displayObject.namespace === "next2d.display.Stage") { /* ... */ }
|
|
498
|
+
|
|
499
|
+
// ✅ OK: static の namespace と比較するとタイポも防げる
|
|
500
|
+
if (displayObject.namespace === Stage.namespace) { /* ... */ }
|
|
501
|
+
|
|
502
|
+
// ✅ OK: Sprite かどうかの判定
|
|
503
|
+
if (displayObject.namespace === Sprite.namespace) { /* ... */ }
|
|
504
|
+
|
|
505
|
+
// ✅ OK: Stage 判定は isStage フラグも使用可能(Stage のみが持つ readonly プロパティ)
|
|
506
|
+
if (displayObject.isStage) { /* ... */ }
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
**namespace を持つ主なクラス:**
|
|
510
|
+
|
|
511
|
+
| クラス | namespace の値 |
|
|
512
|
+
|--------|----------------|
|
|
513
|
+
| `Stage` | `"next2d.display.Stage"` |
|
|
514
|
+
| `Sprite` | `"next2d.display.Sprite"` |
|
|
515
|
+
| `MovieClip` | `"next2d.display.MovieClip"` |
|
|
516
|
+
| `Shape` | `"next2d.display.Shape"` |
|
|
517
|
+
| `Loader` | `"next2d.display.Loader"` |
|
|
518
|
+
| `TextField` | `"next2d.display.TextField"` |
|
|
519
|
+
| `Video` | `"next2d.media.Video"` |
|
|
520
|
+
|
|
521
|
+
**補足:** 継承を含めた機能判定(「Sprite の機能を持っているか」など)には `isStage` / `isSprite` / `isShape` / `isText` / `isVideo` / `isContainerEnabled` / `isTimelineEnabled` の各フラグを使用します。`namespace` は完全一致のクラス判定に使用します。
|
|
522
|
+
|
|
483
523
|
## 関連項目
|
|
484
524
|
|
|
485
525
|
- [MovieClip](/ja/reference/player/movie-clip)
|
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.
|
|
4
|
+
"version": "1.3.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.9.
|
|
56
|
-
"@types/vscode": "^1.
|
|
57
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
58
|
-
"@typescript-eslint/parser": "^8.
|
|
59
|
-
"@vscode/vsce": "^3.9.
|
|
60
|
-
"eslint": "^10.4.
|
|
55
|
+
"@types/node": "^25.9.3",
|
|
56
|
+
"@types/vscode": "^1.115.0",
|
|
57
|
+
"@typescript-eslint/eslint-plugin": "^8.61.0",
|
|
58
|
+
"@typescript-eslint/parser": "^8.61.0",
|
|
59
|
+
"@vscode/vsce": "^3.9.2",
|
|
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.
|
|
64
|
+
"vitest": "^4.1.8"
|
|
65
65
|
},
|
|
66
66
|
"engines": {
|
|
67
67
|
"node": ">=22.0.0",
|