> ## 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.

# 觸控板

> 觸控板

# 觸控板

可讓玩家以類似筆記型電腦觸控板方式互動的類比控制項。

## 屬性

`type` - "touchpad"

`axis` - *object* 或 *array*。單一[軸](/zh-TW/reference/system/touchadaptationkit/types/game-streaming-touch-axis)或[軸](/zh-TW/reference/system/touchadaptationkit/types/game-streaming-touch-axis)陣列，描述此觸控板控制項的對應。

`action` - *object*、*選用*。除了軸對應之外，在觸控時要叫用的[動作](/zh-TW/reference/system/touchadaptationkit/types/game-streaming-touch-action)。

`renderAsButton` - *boolean*、*選用*。預設為 `false`。設定為 `true` 可將觸控板在視覺上呈現為按鈕。

`enabled` - *boolean*、*選用*。預設為 `true`。將控制項的視覺狀態設定為啟用/停用。停用的控制項仍會接收玩家的輸入，但「不會」根據輸入變更視覺樣式。

`visible` - *boolean*、*選用*。預設為 `true`。決定是否向玩家顯示控制項以供互動。若要在遊戲過程中變更，請參閱[使用遊戲狀態變更觸控配置](/zh-TW/build/core-features/common/game-streaming/building-touch-layouts/game-streaming-touch-changing-layouts-game-state#change_state)。

`styles` - *object*、*選用*。自訂控制項的視覺呈現。樣式以每個可設定樣式之狀態的物件來表示。

按鈕控制項可設定下列狀態的樣式：

* `default` - 基本樣式。
* `disabled` - 控制項停用時的樣式。如果未指定，則控制項停用時，會對預設樣式套用轉換，使其呈現停用外觀。
* `idle` - 玩家「未」與控制項互動時套用。
* `moving` - 玩家觸控控制項且未定義 `action` 時套用。
* `activated` - 玩家觸控控制項且已定義 `action` 時套用。

**每個狀態的樣式屬性**

`opacity` - *number*、*選用*。要套用至控制項的不透明度。除了 `disabled` 以外，所有狀態的預設值皆為 1.0。

`background` - *object*、*選用*。可以是[色彩](/zh-TW/reference/system/touchadaptationkit/types/game-streaming-touch-color)或[影像資產](/zh-TW/reference/system/touchadaptationkit/types/game-streaming-touch-asset)。

`faceImage` - *object*、*選用*。可以是[圖示](/zh-TW/reference/system/touchadaptationkit/types/game-streaming-touch-icon)或[影像資產](/zh-TW/reference/system/touchadaptationkit/types/game-streaming-touch-asset)。

**資產尺寸**

對於每個接受影像資產的樣式物件，指定的資產會以基本解析度，以及該基本解析度的 1.5x、2.0x、3.0x 和 4.0x 比例提供。指定影像的解析度必須小於或等於下列最大解析度：

| 物件 | @1.0x | @1.5x | @2.0x | @3.0x | @4.0x |
| :- | :- | :- | :- | :- | :- |
| faceImage | 60x60 | 90x90 | 120x120 | 180x180 | 240x240 |
| background (renderAsButton = true) | 60x60 | 90x90 | 120x120 | 180x180 | 240x240 |
| background (renderAsButton = false) | 120x120 | 90x90 | 240x240 | 360x360 | 480x480 |

## 備註

`touchpad` 最適合用於非固定、無死區的輸出，通常是第一人稱/第三人稱視角遊戲中的視角攝影機。

對於支援滑鼠輸入的遊戲，`touchpad` 可與相對滑鼠搭配使用，以提供經過更精細調整的視角攝影機體驗。

**樣式備註**

當 `renderAsButton` 為 `true` 時：

* 處於 `activated` 狀態時，`faceImage` 會縮小 25% 顯示。
* 對於未使用自訂資產且只有單一 `gamepadX`、`gamepadY`、`gamepadA` 或 `gamepadB` 動作的按鈕，會有標籤和背景色彩的預設樣式。

## 範例

#### 範例 1：具有視角圖示的觸控板

**圖 1. 觸控板控制項**

<img src="https://mintcdn.com/microsoft-4404708b/gzrdvT5kpqAXKEQt/images/gdk/reference/game-streaming-touch-control-images-touchpad.gif?s=964c6d216b29d4d0f46f3bf0c9ae96e2" alt="使用者與觸控板互動" width="400" height="400" data-path="images/gdk/reference/game-streaming-touch-control-images-touchpad.gif" />

```JSON theme={null}
{
    "type": "touchpad",
    "axis": {
        "input": "axisXY",
        "output": "rightJoystick",
        "sensitivity": 3
    },
    "styles": {
        "default" : {
            "faceImage" : {
                "type": "icon",
                "value": "look"
            }
        }
    }
}
```

#### 範例 2：具有視角圖示並呈現為按鈕的觸控板

**圖 1. 按鈕觸控板控制項**

<img src="https://mintcdn.com/microsoft-4404708b/gzrdvT5kpqAXKEQt/images/gdk/reference/game-streaming-touch-control-images-touchpad-renderAsbutton.gif?s=e803a482b67fdb7ad2eaea7608d4b0c3" alt="使用者與呈現為按鈕的觸控板互動" width="200" height="200" data-path="images/gdk/reference/game-streaming-touch-control-images-touchpad-renderAsbutton.gif" />

```JSON theme={null}
{
    "type": "touchpad",
    "renderAsButton": true,
    "axis": {
        "input": "axisXY",
        "output": "rightJoystick",
        "sensitivity": 3
    },
    "styles": {
        "default" : {
            "faceImage" : {
                "type": "icon",
                "value": "look"
            }
        }
    }
}
```

## 需求

**配置版本：** 1.0+ (樣式自配置版本 3.0+ 起提供)


## Related topics

- [模板](/zh-CN/build/core-features/common/game-streaming/tak-command-line-tool/game-streaming-tak-command-line-templates.md)
- [XBOX Accessibility Guidelines (XAG)](/zh-TW/build/game-principles/accessibility/xbox-accessibility-guidelines.md)
- [Windows 與 ROG XBOX Ally 總覽](/zh-TW/paths/windows/overview.md)
- [Touch Adaptation Kit](/zh-CN/reference/system/touchadaptationkit/touchadaptationkit-reference.md)
- [無障礙功能標籤](/zh-TW/build/game-principles/accessibility/accessibility-feature-tags.md)
