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

# 油門

> 油門

# 油門

僅限 Y 軸之搖桿的特殊版本。專為賽車遊戲設計。

## 屬性

`type` - "throttle"

`axisUp` - *string*。控制項上半部對應的扳機。必須是 `"leftTrigger"` 或 `"rightTrigger"`。

`axisDown` - *string*。控制項下半部對應的扳機。必須是 `"leftTrigger"` 或 `"rightTrigger"`。

`relative` - *boolean*、*選用*。控制油門計算其值的方式。如果為 `true`，值會根據使用者初始觸控的位置而定。如果為 `false`，值會根據控制項的中心點而定。預設為 `true`。

`sticky` - *boolean*、*選用*。控制使用者停止觸控控制項時的行為。如果為 `true`，油門會停留在最後的值。如果為 `false`，則會重設為 0。預設為 `false`。

`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` - 基本樣式。
* `activated` - 玩家觸控旋鈕且旋鈕剛好位於軸上 0 值時套用。
* `activatedDown` - 玩家觸控旋鈕並將其移至油門軸的負值 (下方) 區段時套用。
* `activatedUp` - 玩家觸控旋鈕並將其移至油門軸的正值 (上方) 區段時套用。
* `idle` - 玩家*未*與控制項互動，且旋鈕也未 `sticky` 停留在軸的上方區段時套用。
* `idleUp` - 玩家*未*與控制項互動，且旋鈕已移至上方區段並且 `sticky` 已設定為 `true` 時套用。

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

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

[`axisUp`](/zh-TW/reference/system/touchadaptationkit/types/game-streaming-touch-throttle-axis) - *object*、*選用*。[`axis`](/zh-TW/reference/system/touchadaptationkit/types/game-streaming-touch-throttle-axis) 物件，指定油門正值 (上方) 部分的樣式。

[`axisDown`](/zh-TW/reference/system/touchadaptationkit/types/game-streaming-touch-throttle-axis) - *object*、*選用*。[`axis`](/zh-TW/reference/system/touchadaptationkit/types/game-streaming-touch-throttle-axis) 物件，指定油門負值 (下方) 部分的樣式。

[`knob`](/zh-TW/reference/system/touchadaptationkit/types/game-streaming-touch-knob) - *object*、*選用*。[`knob`](/zh-TW/reference/system/touchadaptationkit/types/game-streaming-touch-knob) 物件，指定油門旋鈕部分的樣式。

`indicator` - *object*、*選用*。[stroke](/zh-TW/reference/system/touchadaptationkit/types/game-streaming-touch-stroke)，指定要套用至連接旋鈕與軸上目前位置之元件的樣式。

**資產尺寸**

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

| 物件 | @1.0x | @1.5x | @2.0x | @3.0x | @4.0x |
| :- | :- | :- | :- | :- | :- |
| knob.faceImage | 60x60 | 90x90 | 120x120 | 180x180 | 240x240 |
| knob.background | 60x60 | 90x90 | 120x120 | 180x180 | 240x240 |

## 備註

`throttle` 控制項可讓玩家使用觸控控制項提供扳機的可變壓力。

`throttle` 控制項設計為放置在轉盤的中央位置，並且是該位置與螢幕側邊之間唯一的控制項。

如果玩家可能希望對扳機施加恆定壓力，讓他們設定值後就能用手指執行其他動作，請將 `sticky` 設定為 true。

**樣式備註**

<Warning>透過 Windows 版本的 Content Test Application 進行串流時，並非所有樣式都能正確顯示。</Warning>

## 範例

#### 範例 1：基本油門

**圖 1. 油門控制項**

<img src="https://mintcdn.com/microsoft-4404708b/gzrdvT5kpqAXKEQt/images/gdk/reference/game-streaming-touch-control-images-throttle.gif?s=effd39103fb6dd47dbe5275bdfc07426" alt="使用者與油門互動" width="400" height="400" data-path="images/gdk/reference/game-streaming-touch-control-images-throttle.gif" />

這會使用預設樣式。

```JSON theme={null}
{
    "type": "throttle",
    "axisUp": "rightTrigger",
    "axisDown": "leftTrigger",
    "sticky": true
}
```

#### 範例 2：具有樣式化外框和明確定義圖示的油門

**圖 1. 自訂油門控制項**

<img src="https://mintcdn.com/microsoft-4404708b/gzrdvT5kpqAXKEQt/images/gdk/reference/game-streaming-touch-control-images-throttle-customized.gif?s=bfccc19c022aed00a4e3e14833ab2202" alt="使用者與自訂油門互動" width="400" height="400" data-path="images/gdk/reference/game-streaming-touch-control-images-throttle-customized.gif" />

```JSON theme={null}
{
    "type": "throttle",
    "axisUp": "rightTrigger",
    "axisDown": "leftTrigger",
    "sticky": true,
    "styles": {
        "default": {
            "knob" : {
                "faceImage" : {
                    "type": "icon",
                    "value": "gasPedal"
                }
            },
            "axisUp": {
                "stroke" : {
                    "type": "solid",
                    "color":  "#107C10"
                },
                "cap" : {
                    "type": "color",
                    "value": "#107C10"
                }
            },
            "axisDown": {
                "stroke" : {
                    "type": "solid",
                    "color":  "#ff0000"
                },
                "cap" : {
                    "type": "color",
                    "value": "#ff0000"
                }
            }
        },
        "idleUp" : {
            "knob" : {
                "stroke" : {
                    "type": "solid",
                    "color":  "#107C10"
                }
            },
            "indicator" : {
                "type": "solid",
                "color":  "#107C10"
            }
        },
        "activatedUp" : {
            "indicator" : {
                "type": "solid",
                "color":  "#107C10"
            }
        },
        "activatedDown": {
            "knob" : {
                "faceImage" : {
                    "type": "icon",
                    "value": "brakePedal"
                }
            },
            "indicator" : {
                "type": "solid",
                "color":  "#ff0000"
            }
        }
    }
}
```

## 需求

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