Trigger API Reference\DCEI Functions\Input
Float2 GetMouseWorldPosition2D()
Float2 GetMouseWorldPosition2D()
Description
Returns the map coordinates of the mouse.
Example Usage
local mouse_pos = DCEI.GetMouseWorldPosition2D()
DCEI.LogMessage("x: " .. mouse_pos.x .. " y: " .. mouse_pos.y)
Float2 GetTouchWorldPosition2D()
Float2 GetTouchWorldPosition2D()
Description
Returns the map coordinates of the last touch input. Only works on mobile.
Example Usage
local touch_pos = DCEI.GetTouchWorldPosition2D()
DCEI.LogMessage("x: " .. touch_pos.x .. " y: " .. touch_pos.y)
Float2 GetSwipeScreenPosition()
Float2 GetSwipeScreenPosition()
Description
Return the swipe position based on screen coordinates in pixels.
Example Usage
local swipe_pos = DCEI.GetSwipeScreenPosition()
DCEI.LogMessage("x: " .. swipe_pos.x .. " y: " .. swipe_pos.y)
void HideJoystick(int joystickId = 0)
void HideJoystick(int joystickId = 0)
Description
Parameters
- int
joystickId
the ID of the joystick to hide.
Example Usage
-- Creates the joystick
local joystick_options = {
offset = {
x = 250,
y = 250,
},
}
DCEI.TriggerAddJoystickEventWithJoystickOptions(OnJoystickMove, joystick_options)
-- Creates the button
local button_layout = GMUI.Layout.New({
parent = DCEI.GetUiRootFrame(),
name = "Standard/Button/Button",
})
-- Sets the button to toggle the joystick on and off
local ability_ui_shown = true
DCEI.SetOnClickCallback(button_layout.Button, function()
if ability_ui_shown then
DCEI.HideJoystick(0)
else
DCEI.ShowJoystick(0)
end
ability_ui_shown = not ability_ui_shown
end)
void ShowJoystick(int joystickId = 0)
void ShowJoystick(int joystickId = 0)
Description
Parameters
- int
joystickId
the ID of the joystick to show. Use TriggerAddJoystickEvent or TriggerAddJoystickEventWithJoystickOptions to create a joystick.
Example Usage
-- Creates the joystick
local joystick_options = {
offset = {
x = 250,
y = 250,
},
}
DCEI.TriggerAddJoystickEventWithJoystickOptions(OnJoystickMove, joystick_options)
-- Creates the button
local button_layout = GMUI.Layout.New({
parent = DCEI.GetUiRootFrame(),
name = "Standard/Button/Button",
})
-- Sets the button to toggle the joystick on and off
local ability_ui_shown = true
DCEI.SetOnClickCallback(button_layout.Button, function()
if ability_ui_shown then
DCEI.HideJoystick(0)
else
DCEI.ShowJoystick(0)
end
ability_ui_shown = not ability_ui_shown
end)
Related
- TriggerAddJoystickEvent
- TriggerAddJoystickEventWithJoystickOptions
- TriggerAddJoystickTapEvent
- TriggerAddJoystickSwipeEvent
- TriggerAddJoystickReleaseEvent
- TriggerAddJoystickReleaseEventWithId()
bool HasUserInput()
bool HasUserInput()
Description
Returns true if the current frame has user input.
Example Usage
Core.Timer.Real.New({
duration = 5,
tick = function()
local has_input = DCEI.HasUserInput()
DCEI.LogMessage(tostring(has_input))
end,
})