Now working Textbox

This commit is contained in:
Jan Schuffenhauer
2020-04-19 17:08:16 +02:00
parent c412cfc8fd
commit 0fc4fbeab6
3 changed files with 40 additions and 57 deletions

View File

@@ -5,36 +5,40 @@ export(int, 0, 100) var dialogue_identifier := 0 setget set_dialogue_identifier
signal started
signal finished
var _dialogue_pos = 0
var _dialogue_pos = -1
onready var dialogues := $Dialogues
var _dialogue = []
onready var label = $"CenterContainer/Label"
onready var label = $Label
onready var animation_player = $AnimationPlayer
func _ready():
set_dialogue_identifier(dialogue_identifier)
update_text()
var first_action = true
func _physics_process(delta):
if Input.is_action_just_pressed("skip"):
if(first_action):
set_dialogue_identifier(dialogue_identifier)
update_text()
first_action != first_action
next()
func set_dialogue_identifier(val):
dialogue_identifier = val
_dialogue = dialogues.get_dialogue(val)
_dialogue_pos = 0
animation_player.play("begin_dialouge")
yield(animation_player, "animation_finished")
_dialogue_pos = 0
func update_text():
print(_dialogue)
print(_dialogue[_dialogue_pos])
label.text = _dialogue[_dialogue_pos]
animation_player.play("next_line")
yield(animation_player, "animation_finished")
func next():
_dialogue_pos += 1_
_dialogue_pos += 1
if(_dialogue_pos>=_dialogue.size()):
_dialogue_pos = 0
update_text()

View File

@@ -1,6 +1,7 @@
[gd_scene load_steps=6 format=2]
[gd_scene load_steps=7 format=2]
[ext_resource path="res://Menus/DialogueBox/box.png" type="Texture" id=1]
[ext_resource path="res://Fonts/Harmonic/Harmonic12.tres" type="DynamicFont" id=2]
[ext_resource path="res://Menus/DialogueBox/DialogueBox.gd" type="Script" id=3]
[ext_resource path="res://Menus/DialogueBox/Dialogues.gd" type="Script" id=4]
@@ -9,24 +10,12 @@ resource_name = "begin_dialouge"
length = 0.5
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("CenterContainer:margin_top")
tracks/0/path = NodePath("Label:percent_visible")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.2 ),
"transitions": PoolRealArray( 1, 0.8 ),
"update": 0,
"values": [ 280, 235 ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("CenterContainer/Label:percent_visible")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0, 0.5 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
@@ -37,7 +26,7 @@ tracks/1/keys = {
resource_name = "next_line"
length = 3.0
tracks/0/type = "value"
tracks/0/path = NodePath("CenterContainer/Label:percent_visible")
tracks/0/path = NodePath("Label:percent_visible")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
@@ -49,7 +38,7 @@ tracks/0/keys = {
"values": [ 0.0, 1.0 ]
}
[node name="DialogueBox" type="Control"]
[node name="DialogueBox" type="CenterContainer"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 3 )
@@ -64,23 +53,25 @@ anims/next_line = SubResource( 2 )
[node name="Dialogues" type="Node" parent="."]
script = ExtResource( 4 )
[node name="CenterContainer" type="CenterContainer" parent="."]
margin_right = 480.0
margin_bottom = 31.0
[node name="TextureRect" type="TextureRect" parent="."]
margin_left = 24.0
margin_top = 119.0
margin_right = 456.0
margin_bottom = 150.0
texture = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="TextureRect" type="TextureRect" parent="CenterContainer"]
margin_left = 24.0
margin_right = 456.0
margin_bottom = 31.0
texture = ExtResource( 1 )
[node name="Label" type="Label" parent="CenterContainer"]
margin_left = 208.0
margin_top = 8.0
margin_right = 271.0
margin_bottom = 22.0
text = "Haha. Lol."
[node name="Label" type="Label" parent="."]
margin_left = 187.0
margin_top = 129.0
margin_right = 292.0
margin_bottom = 141.0
custom_fonts/font = ExtResource( 2 )
text = "Hahaha. I hate Humans."
align = 1
percent_visible = 0.0
__meta__ = {
"_edit_use_anchors_": false
}

View File

@@ -25,7 +25,7 @@
script = ExtResource( 2 )
[node name="WallSprite" type="Sprite" parent="."]
position = Vector2( 352, 184 )
position = Vector2( 357.587, 175.62 )
texture = ExtResource( 4 )
region_enabled = true
region_rect = Rect2( 0, 0, 1280, 720 )
@@ -121,31 +121,19 @@ position = Vector2( -107.855, 73.4821 )
[node name="Player" parent="YSort" instance=ExtResource( 1 )]
position = Vector2( 96, -69.5179 )
scale = Vector2( 2, 2 )
debug = true
FRICTION = 200
[node name="Bonfire" parent="." instance=ExtResource( 7 )]
position = Vector2( 448, 104 )
[node name="Bonfire" parent="YSort" instance=ExtResource( 7 )]
position = Vector2( 296, -16 )
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="DragNDropUI" parent="CanvasLayer" instance=ExtResource( 20 )]
ObjectParent = NodePath("../..")
[node name="CenterContainer" type="CenterContainer" parent="CanvasLayer"]
anchor_right = 1.002
anchor_bottom = 0.068
margin_top = 9.0
margin_right = 0.0399475
margin_bottom = 44.64
use_top_left = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="DialogueBox" parent="CanvasLayer/CenterContainer" instance=ExtResource( 19 )]
anchor_right = 0.0
[node name="DialogueBox" parent="CanvasLayer" instance=ExtResource( 19 )]
anchor_bottom = 0.0
margin_bottom = 31.0
[editable path="YSort/minion"]