Next2D FrameworkはAnimationToolで作成したアセットとシームレスに連携できます。
AnimationToolは、Next2D Player用のアニメーションやUIコンポーネントを作成するためのツールです。出力されたJSONファイルをフレームワークで読み込み、MovieClipとして利用できます。
src/
├── ui/
│ ├── content/ # Animation Tool生成コンテンツ
│ │ ├── TopContent.ts
│ │ └── HomeContent.ts
│ │
│ ├── component/ # Atomic Designコンポーネント
│ │ ├── atom/ # 最小単位のコンポーネント
│ │ │ ├── ButtonAtom.ts
│ │ │ └── TextAtom.ts
│ │ ├── molecule/ # Atomを組み合わせたコンポーネント
│ │ │ ├── TopBtnMolecule.ts
│ │ │ └── HomeBtnMolecule.ts
│ │ ├── organism/ # 複数Moleculeの組み合わせ
│ │ ├── template/ # ページテンプレート
│ │ └── page/ # ページコンポーネント
│ │ ├── top/
│ │ │ └── TopPage.ts
│ │ └── home/
│ │ └── HomePage.ts
│ │
│ └── animation/ # コードアニメーション定義
│ └── top/
│ └── TopBtnShowAnimation.ts
│
└── file/ # Animation Tool出力ファイル
└── sample.n2d
Animation Toolで作成したコンテンツをラップするクラスです。
import { MovieClipContent } from "@next2d/framework";
/**
* @see file/sample.n2d
*/
export class TopContent extends MovieClipContent
{
/**
* Animation Tool上で設定したシンボル名を返す
*/
get namespace(): string
{
return "TopContent";
}
}
namespaceプロパティは、Animation Toolで作成したシンボルの名前と一致させます。この名前を使って、読み込まれたJSONデータから対応するMovieClipが生成されます。
Animation ToolのJSONファイルはrouting.jsonのrequestsで読み込みます。
{
"@sample": {
"requests": [
{
"type": "content",
"path": "{{ content.endPoint }}content/sample.json",
"name": "MainContent",
"cache": true
}
]
},
"top": {
"requests": [
{
"type": "cluster",
"path": "@sample"
}
]
}
}
| プロパティ | 型 | 説明 |
|---|---|---|
type | string | "content" を指定 |
path | string | JSONファイルへのパス |
name | string | レスポンスに登録されるキー名 |
cache | boolean | キャッシュするかどうか |
@で始まるキーはクラスターとして定義され、複数のルートで共有できます。type: "cluster"で参照します。
{
"@common": {
"requests": [
{
"type": "content",
"path": "{{ content.endPoint }}common.json",
"name": "CommonContent",
"cache": true
}
]
},
"top": {
"requests": [
{ "type": "cluster", "path": "@common" }
]
},
"home": {
"requests": [
{ "type": "cluster", "path": "@common" }
]
}
}