Mirror cleanup! using Control.rect_clip_content to constrain rig (-=

This commit is contained in:
Harmony Honey 2023-03-07 00:51:34 -05:00
parent 820ee8c8d2
commit 699ab159ad
3 changed files with 17 additions and 65 deletions

View file

@ -6,7 +6,7 @@ export var door_path : NodePath
onready var door_node := get_node_or_null(door_path)
onready var p = Shared.player
onready var back_rect : Rect2 = $Back.get_rect()
onready var rig := $Rig
onready var rig := $Back/Center/Rig
onready var rig_ease := EaseMover.new()
onready var stage := $Stage
@ -27,10 +27,6 @@ func _ready():
rig.global_rotation = 0
rig_ease.clock = rig_ease.time
create_rig()
var sm = $Wall/ColorRect.material
for i in ["col1", "col2"]:
sm.set_shader_param(i, BG.mat.get_shader_param(i))
func _physics_process(delta):
var s = rig_ease.count(delta)
@ -44,6 +40,7 @@ func create_rig():
i.queue_free()
var s = p.sprites.duplicate()
s.get_node("SpriteArea").queue_free()
s.modulate.a = 1
rig.add_child(s)
@ -83,7 +80,7 @@ func idle_frame():
dist = to_local(p.global_position)
rig.position = dist + (offset * dir_x)
rig.visible = back_rect.grow(hide_distance).has_point(rig.position)
rig.visible = back_rect.grow(hide_distance).has_point(rig.position)
if abs(dist.x) > 200:
dir_x = -sign(dist.x)

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=8 format=2]
[gd_scene load_steps=7 format=2]
[ext_resource path="res://src/actor/Mirror.gd" type="Script" id=1]
[ext_resource path="res://src/actor/door/Arrow.tscn" type="PackedScene" id=2]
@ -10,11 +10,6 @@ shader = ExtResource( 3 )
shader_param/col1 = Color( 0, 0.380392, 1, 1 )
shader_param/col2 = Color( 0, 0.921569, 1, 1 )
[sub_resource type="ShaderMaterial" id=4]
shader = ExtResource( 3 )
shader_param/col1 = Color( 0, 0.38, 1, 1 )
shader_param/col2 = Color( 0, 0.92, 1, 1 )
[sub_resource type="ShaderMaterial" id=6]
shader = ExtResource( 3 )
shader_param/col1 = Color( 0, 0.38, 1, 1 )
@ -30,61 +25,21 @@ hide_distance = 100.0
col_size = Vector2( 75, 100 )
image_pos = Vector2( 0, -170 )
[node name="Back" type="Polygon2D" parent="."]
[node name="Back" type="ColorRect" parent="."]
material = SubResource( 5 )
z_index = -25
polygon = PoolVector2Array( 75, 100, -75, 100, -75, -100, 75, -100 )
script = ExtResource( 4 )
size = Vector2( 75, 100 )
margin_left = -75.0
margin_top = -100.0
margin_right = 75.0
margin_bottom = 100.0
rect_clip_content = true
[node name="Rig" type="Node2D" parent="."]
[node name="Center" type="Node2D" parent="Back"]
position = Vector2( 75, 100 )
[node name="Rig" type="Node2D" parent="Back/Center"]
light_mask = 4
z_index = -20
[node name="Wall" type="Node2D" parent="."]
z_index = -15
[node name="ColorRect" type="ColorRect" parent="Wall"]
material = SubResource( 4 )
margin_left = -225.0
margin_top = -100.0
margin_right = -75.0
margin_bottom = 100.0
grow_horizontal = 2
grow_vertical = 2
rect_min_size = Vector2( 100, 200 )
[node name="ColorRect2" type="ColorRect" parent="Wall"]
material = SubResource( 4 )
margin_left = 75.0
margin_top = -100.0
margin_right = 225.0
margin_bottom = 100.0
grow_horizontal = 2
grow_vertical = 2
rect_min_size = Vector2( 100, 200 )
[node name="ColorRect3" type="ColorRect" parent="Wall"]
material = SubResource( 4 )
margin_left = -225.0
margin_top = -250.0
margin_right = 225.0
margin_bottom = -100.0
grow_horizontal = 2
grow_vertical = 2
rect_min_size = Vector2( 350, 100 )
[node name="ColorRect4" type="ColorRect" parent="Wall"]
material = SubResource( 4 )
margin_left = -225.0
margin_top = 100.0
margin_right = 225.0
margin_bottom = 250.0
grow_horizontal = 2
grow_vertical = 2
rect_min_size = Vector2( 350, 100 )
[node name="Border" type="Line2D" parent="Wall"]
[node name="Border" type="Line2D" parent="."]
position = Vector2( -75, -100 )
points = PoolVector2Array( -7, 200, -7, -7, 157, -7, 157, 200 )
width = 15.0
@ -96,6 +51,7 @@ end_cap_mode = 2
[node name="Stage" type="Polygon2D" parent="."]
modulate = Color( 1, 1, 1, 0 )
material = SubResource( 6 )
position = Vector2( -2, -1 )
z_index = 40
z_as_relative = false
polygon = PoolVector2Array( 1000, 1000, -1000, 1000, -1000, -1000, 1000, -1000 )

View file

@ -18,7 +18,6 @@ colors = PoolColorArray( 1, 1, 1, 1, 1, 0, 0, 1, 1, 0.470588, 0.796078, 1, 0.474
sprite_path = NodePath("Images/Petals")
[node name="Spring" type="Node2D" parent="."]
position = Vector2( 2, 1 )
script = ExtResource( 6 )
sprites_path = NodePath("../Images")
add_vel = 5.0
@ -46,12 +45,12 @@ polygon = PoolVector2Array( 8.5, -8.5, 17, -8.5, 21.9962, -6.87664, 25.084, -2.6
script = ExtResource( 1 )
[node name="Area2D" type="Area2D" parent="."]
visible = false
position = Vector2( 0, -25 )
collision_layer = 16
collision_mask = 38
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
visible = false
shape = SubResource( 1 )
[node name="Audio" type="Node2D" parent="."]