> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create 命令

> Create 命令

`create` 命令用于创建触控适配包的源内容（简称未打包适配包），或向现有未打包适配包添加新布局。
这是开始为游戏添加触控适配的一个快速入口点。

下表显示了可用于 `create` 命令的不同子命令。请注意，`create` 命令本身不能单独使用，必须提供子命令。

| 子命令                        | 说明                    |
| -------------------------- | --------------------- |
| [`bundle`](#create-bundle) | 为开发创建新的未打包触控适配包       |
| [`layout`](#create-layout) | 在现有未打包触控适配包中基于模板创建新布局 |

<a id="create-bundle" />

## Create Bundle

`create bundle` 子命令快速创建新触控适配包所需的所有源内容。如果没有为游戏预先存在未打包的适配包，则可以将其作为触控适配的起点。

它创建启动新适配包所需的所有目录和文件。这包括包含不同语言 JSON 布局文件的根[布局](/build/core-features/common/game-streaming/game-streaming-touch-touch-adaptation-bundle#layouts)目录、包含每种语言各种 DPI 资源的根[资源](/build/core-features/common/game-streaming/game-streaming-touch-touch-adaptation-bundle#assets)目录、描述适配包的根包[配置](/build/core-features/common/game-streaming/game-streaming-touch-touch-adaptation-bundle#configuration)文件 (`takxconfig.json`)，以及用于动态布局状态和可重用布局定义的空[上下文](/build/core-features/common/game-streaming/game-streaming-touch-touch-adaptation-bundle#context)文件。

<a id="create-bundle-options" />

### 选项

使用下表中的选项来配置未打包触控适配包的创建。

| 选项                                                               | 说明                                                                                                                                                                                                                                         |
| ---------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `--destination`<br />`--name`                                    | 必需。放置未打包适配包的目标路径。这可以是简单名称或完整路径。<br /> \[!NOTE] 如果目标位置存在任何文件或目录，则必须使用 `--overwrite-destination` 选项先删除它们。<br /> \[!NOTE] 如果使用简单名称而不是路径，则当前工作目录将包含所创建的适配包。                                                                                    |
| `--layouts-directory-name`<br />`--layouts-dir`<br />`--layouts` | 用于存储触控控件布局的子目录名称。这是根 layouts 目录。<br />默认：`layouts`。                                                                                                                                                                                        |
| `--assets-directory-name`<br />`--assets-dir`<br />`--assets`    | 用于存储触控控件资源的子目录名称。这是根 assets 目录。<br />默认：`assets`。                                                                                                                                                                                          |
| `--layout-languages`                                             | 用于在根 layouts 目录下创建语言目录的 IETF 语言标签列表。`neutral` 始终会被创建。<br />默认：空列表。                                                                                                                                                                         |
| `--asset-languages`                                              | 用于在根 assets 目录下创建语言目录的 IETF 语言标签列表。`neutral` 始终会被创建。<br />默认：空列表。                                                                                                                                                                          |
| `--version`                                                      | 包的内容版本。<br />默认：`1.0.0.0`。                                                                                                                                                                                                                 |
| `--version-name`                                                 | 包的内容版本名称。<br />默认：空字符串。                                                                                                                                                                                                                    |
| `--context-file-name`<br />`--context-file`<br />`--context`     | 适配包上下文文件的名称。<br />默认：`context.json`。                                                                                                                                                                                                       |
| `--templates`                                                    | 一个或多个在创建时添加到适配包的模板布局列表。模板始终会被添加到 `neutral` 布局语言目录，以及与 `--layout-languages` 中指定的语言相对应的任何语言目录。<br />[查看可用模板列表。](/build/core-features/common/game-streaming/tak-command-line-tool/game-streaming-tak-command-line-templates)<br />默认：`Blank`。 |
| `--no-templates`                                                 | 不向适配包添加任何模板。如果指定了 `--templates`，则不能使用。<br />默认：`false`。                                                                                                                                                                                    |
| `--overwrite-destination`<br />`--overwrite`                     | 删除目标位置中任何先前的内容。如果目标位置不为空，这是必需的。<br />默认：`false`。                                                                                                                                                                                           |

<a id="create-bundle-examples" />

### 示例

以下示例展示了如何创建新的未打包触控适配包。

***

使用默认空模板创建一个简单的新未打包适配包

```
D:\CreateBundleExamples> tak create bundle --name SampleBundle
Creating loose touch adaptation bundle 'SampleBundle'.
Creating bundle config file.
Creating layouts and assets directories.
Creating language directories.
Creating context file.
Added 1 templates to bundle.
Created loose touch adaptation bundle at 'D:\CreateBundleExamples\SampleBundle'.
```

输出：

```
D:.
└───CreateBundleExamples
    └───SampleBundle
        │   context.json
        │   takxconfig.json
        │
        ├───assets
        │   └───neutral
        │       ├───@1.0x
        │       ├───@1.5x
        │       ├───@2.0x
        │       ├───@3.0x
        │       └───@4.0x
        └───layouts
            └───neutral
                    blank.json
```

***

在不同磁盘上创建具有一些布局语言、模板和自定义目录名称的新适配包

```
C:\> tak create bundle --destination D:\CreateBundleExamples\SomeFolder\AnotherFolder\SampleBundle --layout-languages fr fr-FR en-US --templates Menu Cinematic RacingBasic RacingAdvanced --layouts-dir touch-control-layouts --assets-dir touch-control-assets --context-file touch-control-context
Creating loose touch adaptation bundle 'SampleBundle'.
Creating bundle config file.
Creating layouts and assets directories.
Creating language directories.
Creating context file.
Added 4 templates to bundle.
Created loose touch adaptation bundle at 'D:\CreateBundleExamples\SomeFolder\AnotherFolder\SampleBundle'.
```

输出：

```
D:.
└───CreateBundleExamples
    └───SomeFolder
        └───AnotherFolder
            └───SampleBundle
                │   takxconfig.json
                │   touch-control-context.json
                │
                ├───touch-control-assets
                │   └───neutral
                │       ├───@1.0x
                │       ├───@1.5x
                │       ├───@2.0x
                │       ├───@3.0x
                │       └───@4.0x
                └───touch-control-layouts
                    ├───en
                    │   └───en-US
                    │           cinematic.json
                    │           menu.json
                    │           racing-advanced.json
                    │           racing-basic.json
                    │
                    ├───fr
                    │   │   cinematic.json
                    │   │   menu.json
                    │   │   racing-advanced.json
                    │   │   racing-basic.json
                    │   │
                    │   └───fr-FR
                    │           cinematic.json
                    │           menu.json
                    │           racing-advanced.json
                    │           racing-basic.json
                    │
                    └───neutral
                            cinematic.json
                            menu.json
                            racing-advanced.json
                            racing-basic.json
```

<Note>在命令中，同时使用 --layout-languages 选项指定 'fr' 和 'fr-FR' 会导致模板被添加到每个对应的目录。然而，由于仅指定了 'en-US'，模板只会被添加到 'en-US' 目录中，而不是父级 'en' 目录。无论这些指定情况如何，模板始终会被添加到 neutral 目录。</Note>

生成的包配置文件 (`takxconfig.json`) 将反映表示传递给 `create bundle` 命令的参数的配置。

```json theme={null}
{
  "$schema": "https://raw.githubusercontent.com/microsoft/xbox-game-streaming-tools/main/touch-adaptation-kit/schemas/takxconfig/v1/takxconfig.json",
  "layouts": {
    "path": "touch-control-layouts"
  },
  "assets": {
    "path": "touch-control-assets"
  },
  "context": {
    "path": "touch-control-context.json"
  },
  "version": "1.0.0.0",
  "versionName": "Initial"
}
```

***

<a id="create-layout" />

## Create Layout

`create layout` 子命令支持向现有的未打包适配包添加新布局。可以通过向 `--takx-config-file` 选项提供未打包适配包根目录下所创建的 `takxconfig.json` 文件作为值，将 [`create bundle`](#create-bundle) 产生的输出用作 `create layout` 的输入。

与 [`create bundle`](#create-bundle) 类似，可以在此命令中使用模板创建布局，或默认使用 `Blank`。也支持向多个布局语言目录添加布局，同样适用文件不存在或需要 `--overwrite` 的相同规则。

<a id="create-layout-options" />

### 选项

使用下表中的选项来配置在未打包触控适配包中的布局创建。

| 选项                                       | 说明                                                                                                                                                                                                                      |
| ---------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--takx-config-file`<br />`--takxconfig` | 必需。包配置文件的路径。必须命名为 `takxconfig.json`。                                                                                                                                                                                    |
| `--name`                                 | 布局的名称。这也将是其文件名。<br />建议根据布局最适合游戏的名称来命名。<br />默认：所使用的模板名称（例如 `shooter-basic.json`）。                                                                                                                                      |
| `--languages`                            | 应为其添加布局的 IETF 语言标签列表。无论此处传递的值如何，布局始终会被添加到 `neutral` 布局语言目录。如果在此处指定了语言标签，而在根 layouts 目录下没有找到与之匹配的目录，则将创建这些目录。<br />默认：空列表。                                                                                               |
| `--all-languages`<br />`--all`           | 在包配置文件 (`takxconfig.json`) 中指定的根 layouts 目录下找到的所有语言子目录中创建布局。<br />当指定 `--languages` 时不能设置为 `true`。<br />默认：`false`                                                                                                      |
| `--template`                             | 用于布局的模板。<br />[查看可用模板列表。](/build/core-features/common/game-streaming/tak-command-line-tool/game-streaming-tak-command-line-templates)<br />默认：`Blank`                                                                   |
| `--overwrite`                            | 覆盖任何具有相同名称的现有布局文件。<br />如果根 layouts 目录下的任何语言子目录包含具有相同名称的 JSON 文件，这是必需的。例如，如果 `--name` 是 `test`，`--languages` 设为 `en-US`，且 `en-US` 目录不包含名为 `test.json` 的文件，但 `neutral` 目录中包含，则未指定 `--overwrite` 时命令将不执行。<br />默认：`false` |
| `--set-default`<br />`--default`         | 将创建的布局设置为包配置文件 (`takxconfig.json`) 中的默认布局。<br />默认：`false`                                                                                                                                                              |

<a id="create-layout-examples" />

### 示例

以下示例展示了如何在现有未打包触控适配包中创建新布局。

***

使用默认 `Blank` 模板创建一个简单的新布局。

```
D:\CreateLayoutExamples\SampleBundle> tak create layout --name sample-layout --takxconfig .\takxconfig.json
Verifying bundle configuration file (takxconfig.json).
Verification complete. 0 error(s), 0 warning(s) and 0 note(s) found.
Created layout 'sample-layout' using template 'Blank' in 1 directories.
```

输出：

```
D:.
└───CreateLayoutExample
    └───SampleBundle
        │   context.json
        │   takxconfig.json
        │
        └───layouts
            └───neutral
                    sample-layout.json
```

***

使用特定模板为包中的多种语言创建新布局。

```
D:\CreateLayoutExamples> tak create layout --takxconfig .\SampleBundle\takxconfig.json --template ShooterBasic --languages ja-JP en en-US
Verifying bundle configuration file (takxconfig.json).
Verification complete. 0 error(s), 0 warning(s) and 0 note(s) found.
WARNING: A language directory for 'ja-JP' does not exist under the root layouts directory. It will be created, as well as any relevant parenting directories if applicable to the language.
WARNING: A language directory for 'en' does not exist under the root layouts directory. It will be created, as well as any relevant parenting directories if applicable to the language.
WARNING: A language directory for 'en-US' does not exist under the root layouts directory. It will be created, as well as any relevant parenting directories if applicable to the language.
Created layout 'shooter-basic' using template 'ShooterBasic' in 4 directories.
```

输出：

```
D:.
└───CreateLayoutExample
    └───SampleBundle
        │   context.json
        │   takxconfig.json
        │
        └───layouts
            ├───en
            │   │   shooter-basic.json
            │   │
            │   └───en-US
            │           shooter-basic.json
            │
            ├───ja
            │   └───ja-JP
            │           shooter-basic.json
            │
            └───neutral
                    shooter-basic.json
```

<Note>布局在 'en' 目录中被创建，但没有在 'ja' 目录中被创建，因为前者是唯一被指定给 '--languages' 参数的。</Note>

***

为所有语言创建新布局

```
D:\CreateLayoutExamples> tak create layout --takxconfig .\SampleBundle\takxconfig.json --all-languages
Verifying bundle configuration file (takxconfig.json).
Verification complete. 0 error(s), 0 warning(s) and 0 note(s) found.
Created layout 'blank' using template 'Blank' in 5 directories.
```

输出：

```
D:.
└───SampleBundle
    │   context.json
    │   takxconfig.json
    │
    └───layouts
        ├───en
        │   │   blank.json
        │   │   shooter-basic.json
        │   │
        │   └───en-US
        │           blank.json
        │           shooter-basic.json
        │
        ├───ja
        │   │   blank.json
        │   │
        │   └───ja-JP
        │           blank.json
        │           shooter-basic.json
        │
        └───neutral
                blank.json
                shooter-basic.json
```

***

## 另请参阅

[Touch Adaptation Kit 命令行工具 (tak.exe)](/build/core-features/common/game-streaming/tak-command-line-tool/game-streaming-tak-command-line)


## Related topics

- [Touch Adaptation Kit (TAK) 命令行工具参考](/zh-CN/build/core-features/common/game-streaming/tak-command-line-tool/index.md)
- [第一人称射击触控控制布局](/zh-CN/build/core-features/common/game-streaming/building-touch-layouts/samples/game-streaming-touch-tak-sample-first-person.md)
- [2D 平台跳跃游戏触控控制布局](/zh-CN/build/core-features/common/game-streaming/building-touch-layouts/samples/game-streaming-touch-tak-sample-platformer.md)
- [驾驶类触控控制布局](/zh-CN/build/core-features/common/game-streaming/building-touch-layouts/samples/game-streaming-touch-tak-sample-driving.md)
- [格斗类触控控制布局](/zh-CN/build/core-features/common/game-streaming/building-touch-layouts/samples/game-streaming-touch-tak-sample-fighter.md)
