Create Level Transition Interactable
This commit is contained in:
parent
7106fe35de
commit
2309558593
|
|
@ -44,7 +44,7 @@ _global_script_classes=[ {
|
|||
"language": "GDScript",
|
||||
"path": "res://src/Interactables/HealthPickup.gd"
|
||||
}, {
|
||||
"base": "Area2D",
|
||||
"base": "Reference",
|
||||
"class": "Interactable",
|
||||
"language": "GDScript",
|
||||
"path": "res://lib/templates/Interactable/Interactable.gd"
|
||||
|
|
@ -59,6 +59,11 @@ _global_script_classes=[ {
|
|||
"language": "GDScript",
|
||||
"path": "res://src/classes/Level.gd"
|
||||
}, {
|
||||
"base": "Interactable",
|
||||
"class": "LevelTransition",
|
||||
"language": "GDScript",
|
||||
"path": "res://src/Interactables/LevelTransition.gd"
|
||||
}, {
|
||||
"base": "Node2D",
|
||||
"class": "Modifier_Receiver",
|
||||
"language": "GDScript",
|
||||
|
|
@ -120,6 +125,7 @@ _global_script_class_icons={
|
|||
"Interactable": "",
|
||||
"Interactable_Receiver": "",
|
||||
"Level": "",
|
||||
"LevelTransition": "",
|
||||
"Modifier_Receiver": "",
|
||||
"MovementComponent": "",
|
||||
"Movement_StateReceiver": "",
|
||||
|
|
|
|||
14
src/Interactables/LevelTransition.gd
Normal file
14
src/Interactables/LevelTransition.gd
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
class_name LevelTransition
|
||||
extends Interactable
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
|
||||
|
||||
func trigger_interaction():
|
||||
# This is something that should maybe be extended for every differant interactible.
|
||||
# They could inherit from this base class and implement this function.
|
||||
print("Okay, I'll transition the level now!")
|
||||
10
src/Interactables/LevelTransition.tscn
Normal file
10
src/Interactables/LevelTransition.tscn
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://src/Interactables/LevelTransition.gd" type="Script" id=1]
|
||||
|
||||
[node name="LevelTransition" type="Area2D"]
|
||||
script = ExtResource( 1 )
|
||||
type_name = "LevelTransition"
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_Interactable_Component_body_entered"]
|
||||
[connection signal="body_exited" from="." to="." method="_on_Interactable_Component_body_exited"]
|
||||
|
|
@ -31,4 +31,6 @@ func touch_the_thing(the_thing: Interactable) -> bool:
|
|||
# Do some healthy stuff.
|
||||
the_thing.trigger_interaction()
|
||||
return false
|
||||
if the_thing is LevelTransition:
|
||||
the_thing.trigger_interaction()
|
||||
return true
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
[ext_resource path="res://src/templates/level_templates/LevelTemplate.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://assets/levels/LegacyFantasy-High_Forest/tileset.tres" type="TileSet" id=2]
|
||||
[ext_resource path="res://lib/components/Hitbox_Component.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://lib/templates/Interactable/Interactable.gd" type="Script" id=4]
|
||||
[ext_resource path="res://src/Interactables/LevelTransition.tscn" type="PackedScene" id=4]
|
||||
|
||||
[sub_resource type="CircleShape2D" id=1]
|
||||
radius = 5.09902
|
||||
|
|
@ -38,16 +38,9 @@ modulate = Color( 1, 0, 0, 1 )
|
|||
position = Vector2( 268, 119 )
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="LevelTransition" type="Area2D" parent="." index="5"]
|
||||
collision_layer = 0
|
||||
collision_mask = 2
|
||||
script = ExtResource( 4 )
|
||||
type_name = "LevelTransition"
|
||||
[node name="LevelTransition" parent="." index="5" instance=ExtResource( 4 )]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="LevelTransition" index="0"]
|
||||
modulate = Color( 1, 0, 1, 1 )
|
||||
position = Vector2( 316, 121 )
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[connection signal="body_entered" from="LevelTransition" to="LevelTransition" method="_on_Interactable_Component_body_entered"]
|
||||
[connection signal="body_exited" from="LevelTransition" to="LevelTransition" method="_on_Interactable_Component_body_exited"]
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user