Gamepad Service
摘要
方法
DisableGamepadCursor():() |
EnableGamepadCursor(guiObject: GuiObject?):() |
API 参考
属性
Gamepad Cursor Enabled
代码示例
游戏手柄服务 - 游戏手柄光标启用属性
local gamepadService = game:GetService("GamepadService")
gamepadService:GetPropertyChangedSignal("GamepadCursorEnabled"):Connect(function()
local enabled = gamepadService.GamepadCursorEnabled
if enabled then
-- 当虚拟光标启用时的自定义代码
else
-- 当虚拟光标禁用时的自定义代码
end
end)方法
Disable Gamepad Cursor
Gamepad Service: Disable Gamepad Cursor():()
返回
()
代码示例
游戏手柄服务 - 禁用游戏手柄光标
local gamepadService = game:GetService("GamepadService")
local userInputService = game:GetService("UserInputService")
userInputService.InputBegan:Connect(function(inputObject, gameProcessed)
if inputObject.KeyCode == Enum.KeyCode.ButtonB then
gamepadService:DisableGamepadCursor()
end
end)Enable Gamepad Cursor
参数
| 默认值:nil |
返回
()
代码示例
游戏手柄服务 - 启用游戏手柄光标
local gamepadService = game:GetService("GamepadService")
local userInputService = game:GetService("UserInputService")
local startObject = script.Parent
userInputService.InputBegan:Connect(function(inputObject, gameProcessed)
if inputObject.KeyCode == Enum.KeyCode.ButtonA then
gamepadService:EnableGamepadCursor(startObject)
end
end)