-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_node.gd
54 lines (49 loc) · 1.64 KB
/
test_node.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
extends Control
func render_ui(hello: String) -> GdxRender.GdxRenderOutput:
return GdxRender.render_text('
<TextureRect texture="res://icon.svg" position:="pos" name="HelloTexture" ref:="texture_ref" />
<Control>
<Label text="Hello \'world\'" position:="pos" />
<Label text="Hello world" />
<Control>
<Button text:="btn_text" position:="pos2" size:="Vector2(100, 100)" ref:="btn" />
</Control>
<Control ref:="health">
<ColorRect
:for="i in count"
name:="i"
size:="Vector2(50, 20)"
position:="Vector2(60, 0) * i + Vector2(0, 30)"
visible:="true"
modulate:="h_mod"
/>
</Control>
<HBox anchor_left:="0.0" anchor_right:="1.0" position:="Vector2(0, 60)">
<ColorRect :for="i in 3" custom_minimum_size:="Vector2(50, 20)" color:="color" />
</HBox>
</Control>
', self, {
"pos" = Vector2(100, 100),
"pos2" = Vector2(200, 200),
"btn_text" = "Hello \"" + hello + "\"",
"h_mod" = Color.TRANSPARENT,
"color" = Color.WHITE,
"count" = 5
})
func _ready() -> void:
var output = render_ui("World")
if not output: return
var ref := output.refs.texture_ref as TextureRect
var tween = create_tween().set_trans(Tween.TRANS_SINE).set_loops()
tween.tween_property(ref, "scale", Vector2(1.2, 1.2), 0.25).set_delay(0.1)
tween.tween_property(ref, "scale", Vector2.ONE, 0.25).set_delay(0.1)
tween.play()
var btn := output.refs.btn as Button
btn.pressed.connect(func ():
print("Button pressed")
)
var health := output.refs.health as Control
var h_tw = create_tween().set_trans(Tween.TRANS_SINE)
for r in health.get_children():
h_tw.tween_property(r, "modulate", Color.WHITE, 0.15)
h_tw.play()