feat: 增加欢迎板
- 增加欢迎板场景 - 增加与玩家的交互,点击E弹出弹出框
This commit is contained in:
13
scenes/prefabs/items/WelcomeBoard.gd
Normal file
13
scenes/prefabs/items/WelcomeBoard.gd
Normal file
@@ -0,0 +1,13 @@
|
||||
extends StaticBody2D
|
||||
|
||||
func interact():
|
||||
# Prevent multiple dialogs
|
||||
if get_tree().root.has_node("WelcomeDialog"):
|
||||
return null
|
||||
|
||||
# Spawn the Welcome Dialog
|
||||
var dialog = preload("res://scenes/ui/welcome_dialog.tscn").instantiate()
|
||||
dialog.name = "WelcomeDialog"
|
||||
# Add to the Scene Root (World) or CanvasLayer if it has one
|
||||
get_tree().root.add_child(dialog)
|
||||
return null # Return null prevents Player from showing a bubble
|
||||
1
scenes/prefabs/items/WelcomeBoard.gd.uid
Normal file
1
scenes/prefabs/items/WelcomeBoard.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://d2od22agputjt
|
||||
19
scenes/prefabs/items/welcome_board.tscn
Normal file
19
scenes/prefabs/items/welcome_board.tscn
Normal file
@@ -0,0 +1,19 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://c7k8yay002w4"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ceg3xogmd82yx" path="res://scenes/prefabs/items/WelcomeBoard.gd" id="1_script"]
|
||||
[ext_resource type="Texture2D" uid="uid://v7loa3smfkrd" path="res://Assets/materials/WelcomeBoard.png" id="2_sprite"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_board"]
|
||||
size = Vector2(40, 30)
|
||||
|
||||
[node name="WelcomeBoard" type="StaticBody2D"]
|
||||
collision_layer = 3
|
||||
script = ExtResource("1_script")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("2_sprite")
|
||||
scale = Vector2(0.25, 0.25)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(0, 10)
|
||||
shape = SubResource("RectangleShape2D_board")
|
||||
Reference in New Issue
Block a user