mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-22 16:20:19 +01:00
Tween animation for highlights
This commit is contained in:
parent
45442dd549
commit
20358f78a1
2 changed files with 14 additions and 2 deletions
|
@ -8,9 +8,17 @@ func _ready():
|
|||
|
||||
func _mouse_entered(_area):
|
||||
hovered = true
|
||||
var tween = Tween.new()
|
||||
tween.interpolate_property($Highlight/Sprite.material, "shader_param/hovered", 0, 1, 0.1, Tween.TRANS_CUBIC, Tween.EASE_IN_OUT)
|
||||
add_child(tween)
|
||||
tween.start()
|
||||
|
||||
func _mouse_exited(_area):
|
||||
hovered = false
|
||||
var tween = Tween.new()
|
||||
tween.interpolate_property($Highlight/Sprite.material, "shader_param/hovered", 1, 0, 0.1, Tween.TRANS_CUBIC, Tween.EASE_IN_OUT)
|
||||
add_child(tween)
|
||||
tween.start()
|
||||
|
||||
func _input(event):
|
||||
if event is InputEventMouseButton:
|
||||
|
|
|
@ -4,21 +4,25 @@
|
|||
[ext_resource path="res://nodes/blob.svg" type="Texture" id=2]
|
||||
|
||||
[sub_resource type="CircleShape2D" id=1]
|
||||
radius = 23.5871
|
||||
radius = 63.1532
|
||||
|
||||
[sub_resource type="Shader" id=2]
|
||||
code = "shader_type canvas_item;
|
||||
|
||||
uniform float hovered;
|
||||
|
||||
void fragment() {
|
||||
vec2 center = vec2(0.5, 0.5);
|
||||
float d = distance(UV, center);
|
||||
COLOR = vec4(0.4, 0.65, 1, smoothstep(0.5,0.2,d));
|
||||
COLOR = vec4(0.4 + hovered*0.2, 0.65 + hovered*0.2, 1, smoothstep(0.5,0.2 + hovered*0.1,d));
|
||||
}
|
||||
"
|
||||
custom_defines = ""
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=3]
|
||||
resource_local_to_scene = true
|
||||
shader = SubResource( 2 )
|
||||
shader_param/hovered = 0.0
|
||||
|
||||
[node name="DropArea" type="Node2D" groups=[
|
||||
"drop_areas",
|
||||
|
|
Loading…
Reference in a new issue