Compare commits
1 commit
32811969ea
...
cb570cc0f4
Author | SHA1 | Date | |
---|---|---|---|
cb570cc0f4 |
3 changed files with 23 additions and 35 deletions
|
@ -7,8 +7,6 @@ class_name Sticker extends Area2D
|
||||||
## all the fonctionnalities. You need to assign nodes for the stickerdetection
|
## all the fonctionnalities. You need to assign nodes for the stickerdetection
|
||||||
## and for the sprites.
|
## and for the sprites.
|
||||||
|
|
||||||
#region Exported variables
|
|
||||||
@export var Sticker_mode:bool = false
|
|
||||||
@export_group("Nodes")
|
@export_group("Nodes")
|
||||||
## The look of the object. If it's multiple sprites, they should be under one main sprite
|
## The look of the object. If it's multiple sprites, they should be under one main sprite
|
||||||
@export var WorldSprite:Sprite2D
|
@export var WorldSprite:Sprite2D
|
||||||
|
@ -24,16 +22,10 @@ class_name Sticker extends Area2D
|
||||||
add_child(test)
|
add_child(test)
|
||||||
test.set_owner(get_tree().get_edited_scene_root())
|
test.set_owner(get_tree().get_edited_scene_root())
|
||||||
test = null
|
test = null
|
||||||
#endregion
|
|
||||||
|
|
||||||
var meta:PackedStringArray = ["sticker"]
|
var meta:PackedStringArray = ["sticker"]
|
||||||
var detected_solids:Array
|
var detected_solids:Array
|
||||||
var detected_stickers:Array
|
var detected_stickers:Array
|
||||||
|
|
||||||
|
|
||||||
#region Functions
|
|
||||||
|
|
||||||
|
|
||||||
func _init():
|
func _init():
|
||||||
collision_layer = 2
|
collision_layer = 2
|
||||||
collision_mask = 15
|
collision_mask = 15
|
||||||
|
@ -76,13 +68,11 @@ func _process(delta):
|
||||||
func on_released(CastResult:Array=[]):
|
func on_released(CastResult:Array=[]):
|
||||||
print(self," released")
|
print(self," released")
|
||||||
#TODO: Need a traceresult to know if it should stay in the stickerstate or be released in the world
|
#TODO: Need a traceresult to know if it should stay in the stickerstate or be released in the world
|
||||||
if(detected_solids.size()==0):
|
get_parent().top_level = false
|
||||||
get_parent().top_level = false
|
|
||||||
disable_ChildNodes_collisions(false)
|
|
||||||
update_ChildNodes_visibilty(true)
|
|
||||||
Sticker_mode = false
|
|
||||||
get_parent().reparent(MapManager.current_scene.get_child(0))
|
get_parent().reparent(MapManager.current_scene.get_child(0))
|
||||||
|
disable_ChildNodes_collisions(false)
|
||||||
|
update_ChildNodes_visibilty(true)
|
||||||
|
#on_unhover() # When released behind another sticker, sometimes cursor cannot reach
|
||||||
|
|
||||||
func on_click():
|
func on_click():
|
||||||
print(self," clicked")
|
print(self," clicked")
|
||||||
|
@ -94,29 +84,25 @@ func redraw():
|
||||||
WorldSprite.queue_redraw()
|
WorldSprite.queue_redraw()
|
||||||
|
|
||||||
func on_hover():
|
func on_hover():
|
||||||
if (Sticker_mode == false):
|
if (StickerSprite != null):
|
||||||
if (StickerSprite != null):
|
WorldSprite.visible = false
|
||||||
WorldSprite.visible = false
|
StickerSprite.visible = true
|
||||||
StickerSprite.visible = true
|
elif (WorldSprite != null):
|
||||||
elif (WorldSprite != null):
|
WorldSprite.material = OutlineMat
|
||||||
WorldSprite.material = OutlineMat
|
redraw()
|
||||||
redraw()
|
|
||||||
|
|
||||||
|
|
||||||
func on_unhover():
|
func on_unhover():
|
||||||
if (Sticker_mode == false):
|
if (StickerSprite != null):
|
||||||
if (StickerSprite != null):
|
StickerSprite.visible = false
|
||||||
StickerSprite.visible = false
|
if (WorldSprite != null):
|
||||||
if (WorldSprite != null):
|
WorldSprite.material = null
|
||||||
WorldSprite.material = null
|
WorldSprite.visible = true
|
||||||
WorldSprite.visible = true
|
redraw()
|
||||||
redraw()
|
|
||||||
|
|
||||||
|
|
||||||
func on_grab(_offset:Vector2=Vector2(0.0,0.0)):
|
func on_grab(_offset:Vector2=Vector2(0.0,0.0)):
|
||||||
Sticker_mode = true
|
|
||||||
get_parent().top_level = true
|
get_parent().top_level = true
|
||||||
get_parent().reparent(MapManager)
|
get_parent().reparent(get_tree().root)
|
||||||
update_ChildNodes_visibilty(false)
|
update_ChildNodes_visibilty(false)
|
||||||
disable_ChildNodes_collisions(true)
|
disable_ChildNodes_collisions(true)
|
||||||
|
|
||||||
|
@ -130,4 +116,3 @@ func disable_ChildNodes_collisions(_disable:bool=true):
|
||||||
if (_childNode != self):
|
if (_childNode != self):
|
||||||
_childNode.process_mode = Node.PROCESS_MODE_DISABLED if _disable else Node.PROCESS_MODE_ALWAYS
|
_childNode.process_mode = Node.PROCESS_MODE_DISABLED if _disable else Node.PROCESS_MODE_ALWAYS
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
[ext_resource type="Texture2D" uid="uid://c6acjgu8jnrkl" path="res://textures/sprites/rocks_rock1.tres" id="8_bhcew"]
|
[ext_resource type="Texture2D" uid="uid://c6acjgu8jnrkl" path="res://textures/sprites/rocks_rock1.tres" id="8_bhcew"]
|
||||||
[ext_resource type="Texture2D" uid="uid://dnomlcslicb3k" path="res://textures/sprites/props_fire1.tres" id="10_2ugv3"]
|
[ext_resource type="Texture2D" uid="uid://dnomlcslicb3k" path="res://textures/sprites/props_fire1.tres" id="10_2ugv3"]
|
||||||
[ext_resource type="Texture2D" uid="uid://qsse8uwt06ns" path="res://textures/sprites/plants_bush2.tres" id="11_dibxq"]
|
[ext_resource type="Texture2D" uid="uid://qsse8uwt06ns" path="res://textures/sprites/plants_bush2.tres" id="11_dibxq"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://xx3dwpwk467v" path="res://textures/sprites/stickers_fire1.png" id="14_3fmba"]
|
||||||
[ext_resource type="Texture2D" uid="uid://51ntd0qmjw5j" path="res://textures/sprites/props_woodbarrer.tres" id="14_n4lnm"]
|
[ext_resource type="Texture2D" uid="uid://51ntd0qmjw5j" path="res://textures/sprites/props_woodbarrer.tres" id="14_n4lnm"]
|
||||||
[ext_resource type="Texture2D" uid="uid://xx3dwpwk467v" path="res://textures/sprites/stickers_fire1.png" id="19_d8hr8"]
|
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_yeof8"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_yeof8"]
|
||||||
size = Vector2(202.667, 60.3336)
|
size = Vector2(202.667, 60.3336)
|
||||||
|
@ -155,6 +155,7 @@ metadata/tags = PackedStringArray("sticker")
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Bush1/Sticker"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Bush1/Sticker"]
|
||||||
position = Vector2(-4.46973, -71.6294)
|
position = Vector2(-4.46973, -71.6294)
|
||||||
rotation = 1.6
|
rotation = 1.6
|
||||||
|
scale = Vector2(1, 1)
|
||||||
shape = SubResource("CapsuleShape2D_lfx7b")
|
shape = SubResource("CapsuleShape2D_lfx7b")
|
||||||
|
|
||||||
[node name="Tree2" type="Sprite2D" parent="."]
|
[node name="Tree2" type="Sprite2D" parent="."]
|
||||||
|
@ -236,6 +237,7 @@ metadata/tags = PackedStringArray("sticker")
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Tree4/Sticker"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Tree4/Sticker"]
|
||||||
position = Vector2(0, -253.27)
|
position = Vector2(0, -253.27)
|
||||||
rotation = 0.01
|
rotation = 0.01
|
||||||
|
scale = Vector2(1, 1)
|
||||||
shape = SubResource("CapsuleShape2D_dqo8w")
|
shape = SubResource("CapsuleShape2D_dqo8w")
|
||||||
|
|
||||||
[node name="Bush6" type="Sprite2D" parent="."]
|
[node name="Bush6" type="Sprite2D" parent="."]
|
||||||
|
@ -317,6 +319,7 @@ metadata/tags = PackedStringArray("sticker")
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Bush9/Sticker"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Bush9/Sticker"]
|
||||||
position = Vector2(-4.46976, -71.6294)
|
position = Vector2(-4.46976, -71.6294)
|
||||||
rotation = 1.6
|
rotation = 1.6
|
||||||
|
scale = Vector2(1, 1)
|
||||||
shape = SubResource("CapsuleShape2D_lfx7b")
|
shape = SubResource("CapsuleShape2D_lfx7b")
|
||||||
|
|
||||||
[node name="Bush8" type="Sprite2D" parent="."]
|
[node name="Bush8" type="Sprite2D" parent="."]
|
||||||
|
@ -359,6 +362,7 @@ metadata/tags = PackedStringArray("sticker")
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Bush10/Sticker"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Bush10/Sticker"]
|
||||||
position = Vector2(0, -48.95)
|
position = Vector2(0, -48.95)
|
||||||
rotation = 1.5
|
rotation = 1.5
|
||||||
|
scale = Vector2(1, 1)
|
||||||
shape = SubResource("CapsuleShape2D_b3366")
|
shape = SubResource("CapsuleShape2D_b3366")
|
||||||
|
|
||||||
[node name="Rock1" type="Sprite2D" parent="."]
|
[node name="Rock1" type="Sprite2D" parent="."]
|
||||||
|
@ -513,7 +517,7 @@ shape = SubResource("CircleShape2D_wkggp")
|
||||||
[node name="FirePitSticker" type="Sprite2D" parent="FirePit"]
|
[node name="FirePitSticker" type="Sprite2D" parent="FirePit"]
|
||||||
visible = false
|
visible = false
|
||||||
scale = Vector2(1.8, 1.8)
|
scale = Vector2(1.8, 1.8)
|
||||||
texture = ExtResource("19_d8hr8")
|
texture = ExtResource("14_3fmba")
|
||||||
offset = Vector2(0, -95.355)
|
offset = Vector2(0, -95.355)
|
||||||
|
|
||||||
[connection signal="property_list_changed" from="Bush1" to="Bush1" method="_on_property_list_changed"]
|
[connection signal="property_list_changed" from="Bush1" to="Bush1" method="_on_property_list_changed"]
|
||||||
|
|
|
@ -203,7 +203,6 @@ _data = {
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="MapManager" type="Node2D"]
|
[node name="MapManager" type="Node2D"]
|
||||||
y_sort_enabled = true
|
|
||||||
script = ExtResource("1_p0vo1")
|
script = ExtResource("1_p0vo1")
|
||||||
InitialPlayer = ExtResource("2_fyjh8")
|
InitialPlayer = ExtResource("2_fyjh8")
|
||||||
InitialMap = ExtResource("2_qgqfi")
|
InitialMap = ExtResource("2_qgqfi")
|
||||||
|
|
Loading…
Reference in a new issue