GamepadService
Pokaż przestarzałe
The GamepadService is internally responsible for handling inputs from various controllers, such as Xbox One or PlayStation DualShock controllers. It also handles APIs used with the gamepad virtual cursor. You can enable the gamepad cursor for your experience by setting Enum.VirtualCursorMode under StarterGui to Enabled.
Podsumowanie
Właściwości
The state of the gamepad virtual cursor.
Metody
Disables the gamepad cursor, if currently enabled.
Enables the gamepad cursor or updates its position.
Właściwości
GamepadCursorEnabled
Przykłady kodu
GamepadService - Gamepad Cursor Enabled Property
local gamepadService = game.GamepadService
gamepadService:GetPropertyChangedSignal("GamepadCursorEnabled"):Connect(function()
local enabled = gamepadService.GamepadCursorEnabled
if enabled then
-- Custom code when the virtual cursor is enabled
else
-- Custom code when the virtual cursor is disabled
end
end)
Metody
DisableGamepadCursor
()
Zwroty
()
Przykłady kodu
GamepadService - Disable Gamepad Cursor
local gamepadService = game.GamepadService
local userInputService = game.UserInputService
userInputService.InputBegan:Connect(function(inputObject, gameProcessed)
if inputObject.KeyCode == Enum.KeyCode.ButtonB then
gamepadService:DisableGamepadCursor()
end
end)
EnableGamepadCursor
()
Parametry
Zwroty
()
Przykłady kodu
GamepadService - Enable Gamepad Cursor
local gamepadService = game.GamepadService
local userInputService = game.UserInputService
local startObject = script.Parent
userInputService.InputBegan:Connect(function(inputObject, gameProcessed)
if inputObject.KeyCode == Enum.KeyCode.ButtonA then
gamepadService:EnableGamepadCursor(startObject)
end
end)