mirror of
https://github.com/Insality/druid
synced 2025-09-27 10:02:19 +02:00
Update examples
This commit is contained in:
@@ -1,21 +1,29 @@
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class examples.gamepad_tester: druid.component
|
||||
---@class examples.gamepad_tester: druid.widget
|
||||
---@field root node
|
||||
---@field buttons druid.button
|
||||
---@field buttons_system druid.button
|
||||
---@field button_left_bump druid.button
|
||||
---@field button_right_bump druid.button
|
||||
---@field druid druid.instance
|
||||
local M = component.create("gamepad_tester")
|
||||
---@field button_left druid.button
|
||||
---@field button_right druid.button
|
||||
---@field button_up druid.button
|
||||
---@field button_down druid.button
|
||||
---@field button_x druid.button
|
||||
---@field button_b druid.button
|
||||
---@field button_y druid.button
|
||||
---@field button_a druid.button
|
||||
---@field button_l1 druid.button
|
||||
---@field button_r1 druid.button
|
||||
---@field button_stick_left druid.button
|
||||
---@field button_stick_right druid.button
|
||||
---@field button_start druid.button
|
||||
---@field button_back druid.button
|
||||
---@field trigger_l2 druid.progress
|
||||
---@field trigger_r2 druid.progress
|
||||
---@field stick_left node
|
||||
---@field stick_right node
|
||||
local M = {}
|
||||
|
||||
local STICK_DISTANCE = 50
|
||||
|
||||
---@param template string
|
||||
---@param nodes table<hash, node>
|
||||
function M:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
|
||||
function M:init()
|
||||
self.root = self:get_node("root")
|
||||
|
||||
self.button_left = self.druid:new_button("button_left/button"):set_key_trigger("gamepad_lpad_left")
|
||||
|
@@ -1,25 +1,24 @@
|
||||
local component = require("druid.component")
|
||||
local on_screen_input = require("example.examples.gamepad.on_screen_control.on_screen_input")
|
||||
|
||||
---@class examples.on_screen_control: druid.component
|
||||
---@field druid druid.instance
|
||||
---@class examples.on_screen_control: druid.widget
|
||||
---@field on_screen_input examples.on_screen_input
|
||||
local M = component.create("on_screen_control")
|
||||
---@field character node
|
||||
---@field character_position vector3
|
||||
---@field character_eye_left node
|
||||
---@field character_eye_right node
|
||||
local M = {}
|
||||
|
||||
local CHARACTER_SPEED = 700
|
||||
|
||||
---@param template string
|
||||
---@param nodes table<hash, node>
|
||||
function M:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
|
||||
function M:init()
|
||||
self.character = self:get_node("character")
|
||||
self.character_position = gui.get_position(self.character)
|
||||
|
||||
self.character_eye_left = self:get_node("eye_left")
|
||||
self.character_eye_right = self:get_node("eye_right")
|
||||
|
||||
self.on_screen_input = self.druid:new(on_screen_input, "on_screen_input")
|
||||
self.on_screen_input = self.druid:new_widget(on_screen_input, "on_screen_input")
|
||||
|
||||
self.on_screen_input.on_action:subscribe(self.on_action_button, self)
|
||||
self.on_screen_input.on_movement:subscribe(self.on_movement, self)
|
||||
|
@@ -1,22 +1,25 @@
|
||||
local const = require("druid.const")
|
||||
local event = require("event.event")
|
||||
local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class examples.on_screen_input: druid.component
|
||||
---@field druid druid.instance
|
||||
---@class examples.on_screen_input: druid.widget
|
||||
---@field button_action node
|
||||
---@field on_screen_control node
|
||||
---@field stick_root node
|
||||
---@field stick_position vector3
|
||||
---@field on_action event @()
|
||||
---@field on_movement event @(x: number, y: number, dt: number) X/Y values are in range -1..1
|
||||
---@field on_movement_stop event @()
|
||||
local M = component.create("on_screen_input")
|
||||
---@field is_multitouch boolean
|
||||
---@field _is_stick_drag boolean|number
|
||||
---@field _prev_x number
|
||||
---@field _prev_y number
|
||||
local M = {}
|
||||
|
||||
local STICK_DISTANCE = 80
|
||||
|
||||
---@param template string
|
||||
---@param nodes table<hash, node>
|
||||
function M:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
|
||||
function M:init()
|
||||
self.button_action = self:get_node("on_screen_button")
|
||||
self.on_screen_control = self:get_node("on_screen_stick/root")
|
||||
|
||||
|
Reference in New Issue
Block a user