层(实验性)

一个可以覆盖在基本触控布局之上的子触控布局。

警告

层目前以实验性形式提供,可能会根据早期采用者的反馈更改某些行为。

属性

命名层对象包含以下属性:

center - 对象可选。 屏幕中心显示的控件轮盘

left - 对象可选。 默认情况下显示在玩家左手/拇指下的控件轮盘

lower - 对象可选。 一个对象,可用于将控件放置在控件下行的 leftCentercenterrightCenter 三个槽中的任何一个。

right - 对象可选。 默认情况下显示在玩家右手/拇指下的控件滚轮

upper - 对象可选。 一个对象,可用于将一批控件放置在控件上一行的 right 槽中。

备注

使用 layer 时,在以正常布局(在 centerleftlowerrightupper 位置)使用 control 的每个槽中,可以包含一个控件来替换之前显示的内容,或者使用 blank 控件隐藏以前在该槽中显示的内容。

若要显示 layer,必须具有 button 控件且该控件带有将导致系统显示布局的层操作

示例

此示例从简单的平台动作游戏布局开始,右上角有一个按钮,用于控制是否显示具有高级功能的层。

玩家与布局交互并使用层来显示其他控件

{
    "$schema": "https://raw.githubusercontent.com/microsoft/xbox-game-streaming-tools/main/touch-adaptation-kit/schemas/layout/v3.1/layout.json",
    "content": {
        "left": {
            "inner": [
                {
                    "type": "directionalPad",
                    "scale": 1.5
                }
            ]
        },
        "right": {
            "inner": [
                {
                    "type": "button",
                    "action": "gamepadY",
                    "styles": {
                        "default": {
                            "faceImage": {
                                "type": "icon",
                                "value": "dash"
                            }
                        }
                    }
                },
                {
                    "type": "button",
                    "action": "gamepadA",
                    "styles": {
                        "default": {
                            "faceImage": {
                                "type": "icon",
                                "value": "jump"
                            }
                        }
                    }
                }
            ],
            "outer": [
                null,
                {
                    "type": "button",
                    "action": "gamepadB",
                    "styles": {
                        "default": {
                            "faceImage": {
                                "type": "icon",
                                "value": "specialAbility"
                            }
                        }
                    }
                },
                null,
                null,
                {
                    "type": "button",
                    "action": "gamepadX",
                    "styles": {
                        "default": {
                            "faceImage": {
                                "type": "icon",
                                "value": "fire"
                            }
                        }
                    }
                }
            ]
        },
        "upper": {
            "right": [
                {
                    "type": "button",
                    "action": {
                        "type": "layer",
                        "target": "selectAbility"
                    },
                    "styles": {
                        "default": {
                            "faceImage": {
                                "type": "icon",
                                "value": "add"
                            }
                        }
                    },
                    "toggle" : true
                },
                {
                    "type": "button",
                    "action": "view"
                },
                {
                    "type": "button",
                    "action": "menu"
                }
            ]
        },
        "layers": {
            "selectAbility": {
                "right": {
                    "outer": [
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        {
                            "type": "button",
                            "action": "rightBumper",
                            "styles": {
                                "default": {
                                    "faceImage": {
                                        "type": "icon",
                                        "value": "ability2"
                                    }
                                }
                            }
                        },
                        {
                            "type": "button",
                            "action": "leftBumper",
                            "styles": {
                                "default": {
                                    "faceImage": {
                                        "type": "icon",
                                        "value": "ability"
                                    }
                                }
                            }
                        }
                    ]
                }
            }
        }
    }
}

另请参阅

触控适配工具包参考
空白控件
层操作
Layout