按钮闪烁

This commit is contained in:
TsubakiLoL 2024-12-16 11:19:12 +08:00
parent 9bac26b7db
commit 3ea7f0eeb9
3 changed files with 35 additions and 8 deletions

View File

@ -30,7 +30,7 @@ func _ready() -> void:
if !OnClickIsCooling: if !OnClickIsCooling:
SelectNode = _node SelectNode = _node
OnClickIsCooling = true OnClickIsCooling = true
Onclick.emit(_node.index) Onclick.emit(_node.get_index())
) )
pass # Replace with function body. pass # Replace with function body.

View File

@ -110,7 +110,6 @@ script = ExtResource("10_jyc6b")
TextureNormal = ExtResource("3_t55mh") TextureNormal = ExtResource("3_t55mh")
TexturePressed = ExtResource("3_r83c5") TexturePressed = ExtResource("3_r83c5")
styleBox = SubResource("StyleBoxTexture_bqmim") styleBox = SubResource("StyleBoxTexture_bqmim")
is_Scale = true
[node name="TextureRect" type="TextureRect" parent="HBoxContainer/margin/VBoxContainer/GridContainer/Record"] [node name="TextureRect" type="TextureRect" parent="HBoxContainer/margin/VBoxContainer/GridContainer/Record"]
custom_minimum_size = Vector2(74, 74) custom_minimum_size = Vector2(74, 74)
@ -147,7 +146,6 @@ script = ExtResource("10_jyc6b")
TextureNormal = ExtResource("6_q5g71") TextureNormal = ExtResource("6_q5g71")
TexturePressed = ExtResource("7_3wr4h") TexturePressed = ExtResource("7_3wr4h")
styleBox = SubResource("StyleBoxTexture_bqmim") styleBox = SubResource("StyleBoxTexture_bqmim")
is_Scale = true
[node name="TextureRect" type="TextureRect" parent="HBoxContainer/margin/VBoxContainer/GridContainer/Build"] [node name="TextureRect" type="TextureRect" parent="HBoxContainer/margin/VBoxContainer/GridContainer/Build"]
custom_minimum_size = Vector2(74, 74) custom_minimum_size = Vector2(74, 74)
@ -185,7 +183,6 @@ script = ExtResource("10_jyc6b")
TextureNormal = ExtResource("8_0e4lg") TextureNormal = ExtResource("8_0e4lg")
TexturePressed = ExtResource("9_gdew3") TexturePressed = ExtResource("9_gdew3")
styleBox = SubResource("StyleBoxTexture_bqmim") styleBox = SubResource("StyleBoxTexture_bqmim")
is_Scale = true
[node name="TextureRect" type="TextureRect" parent="HBoxContainer/margin/VBoxContainer/GridContainer/Export"] [node name="TextureRect" type="TextureRect" parent="HBoxContainer/margin/VBoxContainer/GridContainer/Export"]
custom_minimum_size = Vector2(74, 74) custom_minimum_size = Vector2(74, 74)
@ -237,7 +234,6 @@ script = ExtResource("10_jyc6b")
TextureNormal = ExtResource("11_px13j") TextureNormal = ExtResource("11_px13j")
TexturePressed = ExtResource("12_ljpgt") TexturePressed = ExtResource("12_ljpgt")
styleBox = SubResource("StyleBoxTexture_bqmim") styleBox = SubResource("StyleBoxTexture_bqmim")
is_Scale = true
[node name="TextureRect" type="TextureRect" parent="HBoxContainer/margin/VBoxContainer/GridContainer/Download"] [node name="TextureRect" type="TextureRect" parent="HBoxContainer/margin/VBoxContainer/GridContainer/Download"]
custom_minimum_size = Vector2(74, 74) custom_minimum_size = Vector2(74, 74)
@ -275,7 +271,6 @@ script = ExtResource("10_jyc6b")
TextureNormal = ExtResource("13_8lrx3") TextureNormal = ExtResource("13_8lrx3")
TexturePressed = ExtResource("15_f66s7") TexturePressed = ExtResource("15_f66s7")
styleBox = SubResource("StyleBoxTexture_bqmim") styleBox = SubResource("StyleBoxTexture_bqmim")
is_Scale = true
[node name="TextureRect" type="TextureRect" parent="HBoxContainer/margin/VBoxContainer/GridContainer/Upload"] [node name="TextureRect" type="TextureRect" parent="HBoxContainer/margin/VBoxContainer/GridContainer/Upload"]
custom_minimum_size = Vector2(74, 74) custom_minimum_size = Vector2(74, 74)

View File

@ -2,12 +2,14 @@ extends BaseControl
@export var TextureNormal :Texture2D @export var TextureNormal :Texture2D
@export var TexturePressed : Texture2D @export var TexturePressed : Texture2D
#用来播放动画的tween
var animation_tween
func _ready() -> void: func _ready() -> void:
super._ready() super._ready()
self.button_down.connect(_on_button_down) self.button_down.connect(_on_button_down)
self.button_up.connect(_on_button_up) self.button_up.connect(_on_button_up)
self.on_click.connect(_on_click)
$TextureRect.texture=TextureNormal $TextureRect.texture=TextureNormal
self.flat=true self.flat=true
@ -22,4 +24,34 @@ func _on_button_up() -> void:
$TextureRect.texture=TextureNormal $TextureRect.texture=TextureNormal
pass # Replace with function body. pass # Replace with function body.
var is_selected var is_select:bool:
set(value):
if is_select!=value:
if value:
if animation_tween!=null:
animation_tween.kill()
animation_tween=create_tween()
animation_tween.tween_callback(set_texture.bind(TexturePressed)).set_delay(0.15)
animation_tween.tween_callback(set_texture.bind(TextureNormal)).set_delay(0.15)
animation_tween.tween_callback(set_texture.bind(TexturePressed)).set_delay(0.15)
animation_tween.tween_callback(set_texture.bind(TextureNormal)).set_delay(0.15)
animation_tween.tween_callback(set_texture.bind(TexturePressed)).set_delay(0.15)
else:
if animation_tween!=null:
animation_tween.kill()
animation_tween=null
set_texture(TextureNormal)
pass
is_select=value
func set_texture(texture:Texture2D):
$TextureRect.texture=texture
func _on_click(node):
is_select=not is_select
pass