mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-29 21:45:09 +03:00
Shader as Target Highlights
This commit is contained in:
parent
8760ad7178
commit
45442dd549
@ -16,12 +16,18 @@ func _input(event):
|
|||||||
if event is InputEventMouseButton:
|
if event is InputEventMouseButton:
|
||||||
if event.button_index == BUTTON_LEFT and !event.pressed and hovered:
|
if event.button_index == BUTTON_LEFT and !event.pressed and hovered:
|
||||||
if highlighted and game.dragged_object:
|
if highlighted and game.dragged_object:
|
||||||
game.dragged_object.dropped_on($"..")
|
game.dragged_object.dropped_on(get_parent_with_type())
|
||||||
|
|
||||||
func _set_highlighted(new_highlighted):
|
func _set_highlighted(new_highlighted):
|
||||||
highlighted = new_highlighted
|
highlighted = new_highlighted
|
||||||
$Highlight.visible = highlighted
|
$Highlight.visible = highlighted
|
||||||
|
|
||||||
|
func get_parent_with_type():
|
||||||
|
var parent = get_parent()
|
||||||
|
while(!parent.get("type")):
|
||||||
|
parent = parent.get_parent()
|
||||||
|
return parent
|
||||||
|
|
||||||
func highlight(type):
|
func highlight(type):
|
||||||
if get_parent().type == type:
|
if get_parent_with_type().type == type:
|
||||||
_set_highlighted(true)
|
_set_highlighted(true)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=4 format=2]
|
[gd_scene load_steps=6 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://scenes/drop_area.gd" type="Script" id=1]
|
[ext_resource path="res://scenes/drop_area.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://nodes/blob.svg" type="Texture" id=2]
|
[ext_resource path="res://nodes/blob.svg" type="Texture" id=2]
|
||||||
@ -6,11 +6,24 @@
|
|||||||
[sub_resource type="CircleShape2D" id=1]
|
[sub_resource type="CircleShape2D" id=1]
|
||||||
radius = 23.5871
|
radius = 23.5871
|
||||||
|
|
||||||
|
[sub_resource type="Shader" id=2]
|
||||||
|
code = "shader_type canvas_item;
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
"
|
||||||
|
custom_defines = ""
|
||||||
|
|
||||||
|
[sub_resource type="ShaderMaterial" id=3]
|
||||||
|
shader = SubResource( 2 )
|
||||||
|
|
||||||
[node name="DropArea" type="Node2D" groups=[
|
[node name="DropArea" type="Node2D" groups=[
|
||||||
"drop_areas",
|
"drop_areas",
|
||||||
]]
|
]]
|
||||||
position = Vector2( -0.197731, 0.0673599 )
|
position = Vector2( -0.197731, 0.0673599 )
|
||||||
z_index = 2
|
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="Area2D" type="Area2D" parent="."]
|
[node name="Area2D" type="Area2D" parent="."]
|
||||||
@ -24,9 +37,10 @@ shape = SubResource( 1 )
|
|||||||
[node name="Highlight" type="Node2D" parent="."]
|
[node name="Highlight" type="Node2D" parent="."]
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite" parent="Highlight"]
|
[node name="Sprite" type="Sprite" parent="Highlight"]
|
||||||
modulate = Color( 0.847059, 0.788235, 0.996078, 0.533333 )
|
modulate = Color( 1, 1, 1, 0.643137 )
|
||||||
position = Vector2( 0.177797, -0.65835 )
|
material = SubResource( 3 )
|
||||||
scale = Vector2( 1.23678, 1.23678 )
|
position = Vector2( -0.102825, -0.377726 )
|
||||||
|
scale = Vector2( 2.25501, 2.25501 )
|
||||||
texture = ExtResource( 2 )
|
texture = ExtResource( 2 )
|
||||||
[connection signal="area_entered" from="Area2D" to="." method="_mouse_entered"]
|
[connection signal="area_entered" from="Area2D" to="." method="_mouse_entered"]
|
||||||
[connection signal="area_exited" from="Area2D" to="." method="_mouse_exited"]
|
[connection signal="area_exited" from="Area2D" to="." method="_mouse_exited"]
|
||||||
|
@ -17,6 +17,19 @@ __meta__ = {
|
|||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[node name="Control" type="Control" parent="."]
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="DropArea" parent="Control" instance=ExtResource( 4 )]
|
||||||
|
show_behind_parent = false
|
||||||
|
position = Vector2( 0, 0 )
|
||||||
|
|
||||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
@ -80,6 +93,3 @@ custom_fonts/font = ExtResource( 2 )
|
|||||||
text = "filename"
|
text = "filename"
|
||||||
align = 1
|
align = 1
|
||||||
autowrap = true
|
autowrap = true
|
||||||
|
|
||||||
[node name="DropArea" parent="." instance=ExtResource( 4 )]
|
|
||||||
position = Vector2( 88.6643, 48.5029 )
|
|
||||||
|
Loading…
Reference in New Issue
Block a user