make it work
This commit is contained in:
parent
6489729878
commit
91281d9cb7
|
@ -2,19 +2,8 @@ extends Node2D
|
||||||
|
|
||||||
@export_enum("angry", "neutral", "happy", "laugh") var expression
|
@export_enum("angry", "neutral", "happy", "laugh") var expression
|
||||||
|
|
||||||
@export var sprite_laugh : Sprite2D
|
|
||||||
@export var sprite_happy : Sprite2D
|
|
||||||
@export var sprite_neutral : Sprite2D
|
|
||||||
@export var sprite_unhappy : Sprite2D
|
|
||||||
|
|
||||||
var person_controller : AudienceMember
|
var person_controller : AudienceMember
|
||||||
|
var expression_map = {}
|
||||||
var expression_map = {
|
|
||||||
"angry" : sprite_unhappy,
|
|
||||||
"neutral" : sprite_neutral,
|
|
||||||
"happy" : sprite_happy,
|
|
||||||
"laugh" : sprite_laugh,
|
|
||||||
}
|
|
||||||
|
|
||||||
const expression_change_speed : float = 1.5
|
const expression_change_speed : float = 1.5
|
||||||
const color_transparent : Color = Color(1, 1, 1, 0)
|
const color_transparent : Color = Color(1, 1, 1, 0)
|
||||||
|
@ -22,21 +11,24 @@ const color_visible : Color = Color(1, 1, 1, 1)
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
person_controller = null
|
expression_map = {
|
||||||
|
"angry" : $Unhappy,
|
||||||
|
"neutral" : $Neutral,
|
||||||
|
"happy" : $Happy,
|
||||||
|
"laugh" : $Laugh,
|
||||||
|
}
|
||||||
|
person_controller = get_node("../../../Person")
|
||||||
expression = person_controller.expression
|
expression = person_controller.expression
|
||||||
reset_face()
|
reset_face()
|
||||||
|
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
if expression != person_controller.expression:
|
if expression != person_controller.expression:
|
||||||
update_face(person_controller.expression)
|
update_face(person_controller.expression)
|
||||||
expression != person_controller.expression
|
expression = person_controller.expression
|
||||||
|
|
||||||
func reset_face():
|
func reset_face():
|
||||||
for expr in expression_map:
|
for expr in expression_map:
|
||||||
if expr == expression:
|
expression_map[expr].modulate = color_transparent.lerp(color_visible, expr == expression)
|
||||||
expression_map[expr].modulate = color_visible
|
|
||||||
else:
|
|
||||||
expression_map[expr].modulate = color_transparent
|
|
||||||
|
|
||||||
func update_face(new_expression: String):
|
func update_face(new_expression: String):
|
||||||
var tween = get_tree().create_tween().bind_node(self).set_parallel().set_trans(Tween.TRANS_LINEAR)
|
var tween = get_tree().create_tween().bind_node(self).set_parallel().set_trans(Tween.TRANS_LINEAR)
|
||||||
|
|
|
@ -5,16 +5,17 @@
|
||||||
[ext_resource type="Texture2D" uid="uid://oeljmd05bkvj" path="res://sprites/faces/curly_neutral.png" id="2_54uqk"]
|
[ext_resource type="Texture2D" uid="uid://oeljmd05bkvj" path="res://sprites/faces/curly_neutral.png" id="2_54uqk"]
|
||||||
[ext_resource type="Texture2D" uid="uid://5iygla17stpm" path="res://sprites/faces/curly_not_amused.png" id="3_2t0h4"]
|
[ext_resource type="Texture2D" uid="uid://5iygla17stpm" path="res://sprites/faces/curly_not_amused.png" id="3_2t0h4"]
|
||||||
|
|
||||||
[node name="FaceCurly" type="Node2D" node_paths=PackedStringArray("sprite_happy", "sprite_neutral", "sprite_unhappy")]
|
[node name="FaceCurly" type="Node2D"]
|
||||||
script = ExtResource("1_vcbhp")
|
script = ExtResource("1_vcbhp")
|
||||||
sprite_happy = NodePath("Happy")
|
|
||||||
sprite_neutral = NodePath("Neutral")
|
|
||||||
sprite_unhappy = NodePath("Unhappy")
|
|
||||||
|
|
||||||
[node name="Happy" type="Sprite2D" parent="."]
|
[node name="Happy" type="Sprite2D" parent="."]
|
||||||
modulate = Color(1, 1, 1, 0)
|
modulate = Color(1, 1, 1, 0)
|
||||||
texture = ExtResource("1_7pet0")
|
texture = ExtResource("1_7pet0")
|
||||||
|
|
||||||
|
[node name="Laugh" type="Sprite2D" parent="."]
|
||||||
|
modulate = Color(1, 1, 1, 0)
|
||||||
|
texture = ExtResource("1_7pet0")
|
||||||
|
|
||||||
[node name="Neutral" type="Sprite2D" parent="."]
|
[node name="Neutral" type="Sprite2D" parent="."]
|
||||||
texture = ExtResource("2_54uqk")
|
texture = ExtResource("2_54uqk")
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,9 @@
|
||||||
[ext_resource type="Texture2D" uid="uid://b0ppuni7v257g" path="res://sprites/faces/moritz_neutral.svg" id="3_s33ae"]
|
[ext_resource type="Texture2D" uid="uid://b0ppuni7v257g" path="res://sprites/faces/moritz_neutral.svg" id="3_s33ae"]
|
||||||
[ext_resource type="Texture2D" uid="uid://7tn6ynr07tns" path="res://sprites/faces/moritz_not_amused.svg" id="4_0rss5"]
|
[ext_resource type="Texture2D" uid="uid://7tn6ynr07tns" path="res://sprites/faces/moritz_not_amused.svg" id="4_0rss5"]
|
||||||
|
|
||||||
[node name="FaceMoritz" type="Node2D" node_paths=PackedStringArray("sprite_happy", "sprite_neutral", "sprite_unhappy")]
|
[node name="FaceMoritz" type="Node2D" node_paths=PackedStringArray("sprite_laugh", "sprite_happy", "sprite_neutral", "sprite_unhappy")]
|
||||||
script = ExtResource("1_abnxg")
|
script = ExtResource("1_abnxg")
|
||||||
|
sprite_laugh = NodePath("Laugh")
|
||||||
sprite_happy = NodePath("Happy")
|
sprite_happy = NodePath("Happy")
|
||||||
sprite_neutral = NodePath("Neutral")
|
sprite_neutral = NodePath("Neutral")
|
||||||
sprite_unhappy = NodePath("Unhappy")
|
sprite_unhappy = NodePath("Unhappy")
|
||||||
|
@ -15,6 +16,10 @@ sprite_unhappy = NodePath("Unhappy")
|
||||||
modulate = Color(1, 1, 1, 0)
|
modulate = Color(1, 1, 1, 0)
|
||||||
texture = ExtResource("2_0u1g1")
|
texture = ExtResource("2_0u1g1")
|
||||||
|
|
||||||
|
[node name="Laugh" type="Sprite2D" parent="."]
|
||||||
|
modulate = Color(1, 1, 1, 0)
|
||||||
|
texture = ExtResource("2_0u1g1")
|
||||||
|
|
||||||
[node name="Neutral" type="Sprite2D" parent="."]
|
[node name="Neutral" type="Sprite2D" parent="."]
|
||||||
texture = ExtResource("3_s33ae")
|
texture = ExtResource("3_s33ae")
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,9 @@
|
||||||
[ext_resource type="Texture2D" uid="uid://ijs3777dtv0n" path="res://sprites/faces/ronald_neutral.svg" id="3_ko187"]
|
[ext_resource type="Texture2D" uid="uid://ijs3777dtv0n" path="res://sprites/faces/ronald_neutral.svg" id="3_ko187"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cn7dhkoupxvt8" path="res://sprites/faces/ronald_not_amused.svg" id="4_cf5hk"]
|
[ext_resource type="Texture2D" uid="uid://cn7dhkoupxvt8" path="res://sprites/faces/ronald_not_amused.svg" id="4_cf5hk"]
|
||||||
|
|
||||||
[node name="FaceCurly" type="Node2D" node_paths=PackedStringArray("sprite_happy", "sprite_neutral", "sprite_unhappy")]
|
[node name="FaceCurly" type="Node2D" node_paths=PackedStringArray("sprite_laugh", "sprite_happy", "sprite_neutral", "sprite_unhappy")]
|
||||||
script = ExtResource("1_8nd6f")
|
script = ExtResource("1_8nd6f")
|
||||||
|
sprite_laugh = NodePath("Laugh")
|
||||||
sprite_happy = NodePath("Happy")
|
sprite_happy = NodePath("Happy")
|
||||||
sprite_neutral = NodePath("Neutral")
|
sprite_neutral = NodePath("Neutral")
|
||||||
sprite_unhappy = NodePath("Unhappy")
|
sprite_unhappy = NodePath("Unhappy")
|
||||||
|
@ -21,3 +22,7 @@ texture = ExtResource("3_ko187")
|
||||||
[node name="Unhappy" type="Sprite2D" parent="."]
|
[node name="Unhappy" type="Sprite2D" parent="."]
|
||||||
modulate = Color(1, 1, 1, 0)
|
modulate = Color(1, 1, 1, 0)
|
||||||
texture = ExtResource("4_cf5hk")
|
texture = ExtResource("4_cf5hk")
|
||||||
|
|
||||||
|
[node name="Laugh" type="Sprite2D" parent="."]
|
||||||
|
modulate = Color(1, 1, 1, 0)
|
||||||
|
texture = ExtResource("2_512yk")
|
||||||
|
|
Loading…
Reference in New Issue