-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from gmuGADIG/Transition-areas
Transition areas
- Loading branch information
Showing
3 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class_name transition_scene extends Area2D | ||
|
||
var _player: Player | ||
## The scene that you want to transition to, make sure to use the UID. | ||
@export var scene: String | ||
|
||
func _ready() -> void: | ||
# wait a single frame in case our _ready was called before the player's | ||
await get_tree().process_frame | ||
_player = Player.instance | ||
#make sure there is a scene and a player | ||
assert(scene != "n", "The scene to transition to is not assigned!") | ||
assert(_player != null, "No player exists in the scene!") | ||
|
||
func _on_body_entered(body: Node2D) -> void: | ||
var player := body as Player | ||
if player != null: | ||
SceneTransition.change_scene(load(scene)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://bwo5q4wroaigc"] | ||
|
||
[ext_resource type="Script" path="res://world/transition_trigger/transition_trigger.gd" id="1_xpvta"] | ||
|
||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_3rema"] | ||
|
||
[node name="TransitionScene" type="Area2D"] | ||
collision_layer = 0 | ||
collision_mask = 2 | ||
script = ExtResource("1_xpvta") | ||
|
||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] | ||
shape = SubResource("RectangleShape2D_3rema") | ||
|
||
[connection signal="body_entered" from="." to="." method="_on_body_entered"] |