mirror of
https://github.com/Insality/druid
synced 2025-09-27 18:12:21 +02:00
Update example with new brand one
This commit is contained in:
35
example/examples/basic/timer/basic_timer.gui
Normal file
35
example/examples/basic/timer/basic_timer.gui
Normal file
@@ -0,0 +1,35 @@
|
||||
fonts {
|
||||
name: "text_bold"
|
||||
font: "/example/assets/fonts/text_bold.font"
|
||||
}
|
||||
nodes {
|
||||
size {
|
||||
x: 200.0
|
||||
y: 100.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
id: "root"
|
||||
inherit_alpha: true
|
||||
size_mode: SIZE_MODE_AUTO
|
||||
visible: false
|
||||
}
|
||||
nodes {
|
||||
scale {
|
||||
x: 2.0
|
||||
y: 2.0
|
||||
}
|
||||
size {
|
||||
x: 200.0
|
||||
y: 100.0
|
||||
}
|
||||
type: TYPE_TEXT
|
||||
text: "5:09"
|
||||
font: "text_bold"
|
||||
id: "text"
|
||||
parent: "root"
|
||||
inherit_alpha: true
|
||||
outline_alpha: 0.0
|
||||
shadow_alpha: 0.0
|
||||
}
|
||||
material: "/builtins/materials/gui.material"
|
||||
adjust_reference: ADJUST_REFERENCE_PARENT
|
33
example/examples/basic/timer/basic_timer.lua
Normal file
33
example/examples/basic/timer/basic_timer.lua
Normal file
@@ -0,0 +1,33 @@
|
||||
local event = require("druid.event")
|
||||
local timer = require("druid.extended.timer")
|
||||
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class basic_timer: druid.component
|
||||
---@field druid druid_instance
|
||||
---@field root node
|
||||
---@field text druid.text
|
||||
local M = component.create("basic_timer")
|
||||
|
||||
|
||||
---@param template string
|
||||
---@param nodes table<hash, node>
|
||||
function M:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
|
||||
self.root = self:get_node("root")
|
||||
self.timer = self.druid:new(timer, "text")
|
||||
|
||||
local time = 5
|
||||
self.timer:set_interval(time, 0)
|
||||
self.timer.on_timer_end:subscribe(function()
|
||||
time = time + 5
|
||||
self.timer:set_interval(time, 0)
|
||||
self.on_cycle_end:trigger()
|
||||
end)
|
||||
|
||||
self.on_cycle_end = event.create()
|
||||
end
|
||||
|
||||
|
||||
return M
|
Reference in New Issue
Block a user