parody: adding highlight feature to postIt
This commit is contained in:
parent
513c6c1e77
commit
83da4b0f1f
|
|
@ -3,18 +3,53 @@
|
|||
extends Area2D
|
||||
class_name PostIt
|
||||
var sibling
|
||||
var wiggle_pos: float = randf_range(-100, 100)
|
||||
var wiggle_intensity: float = 0
|
||||
var noise: Noise = FastNoiseLite.new()
|
||||
var shift_tween
|
||||
var modulate_tween
|
||||
|
||||
@export var text: String = "" :
|
||||
set (value):
|
||||
if is_inside_tree() or Engine.is_editor_hint():
|
||||
$Label.text = value
|
||||
$BackgroundSprite.frame = text.hash() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation)
|
||||
$Content/Label.text = value
|
||||
$Content/BackgroundSprite.frame = text.hash() % $Content/BackgroundSprite.sprite_frames.get_frame_count($Content/BackgroundSprite.animation)
|
||||
text = value
|
||||
|
||||
@export var shift_by: Vector2 = Vector2(-32, 0)
|
||||
@export_color_no_alpha var highlight_color: Color = Color(1.5, 1.5, 1.5)
|
||||
@export var highlighted: bool = false:
|
||||
set(highlight):
|
||||
if highlight != highlighted:
|
||||
highlighted = highlight
|
||||
|
||||
if is_inside_tree() and is_node_ready():
|
||||
if modulate_tween: modulate_tween.kill()
|
||||
if shift_tween: shift_tween.kill()
|
||||
if highlighted:
|
||||
modulate_tween = get_tree().create_tween()
|
||||
modulate_tween.tween_property(self, "modulate", highlight_color, 0.1)
|
||||
shift_tween = get_tree().create_tween()
|
||||
shift_tween.tween_property($Content, "position", shift_by, 0.2)
|
||||
else:
|
||||
modulate_tween = get_tree().create_tween()
|
||||
modulate_tween.tween_property(self, "modulate", Color(1, 1, 1), 0.3)
|
||||
shift_tween = get_tree().create_tween()
|
||||
shift_tween.tween_property($Content, "position", Vector2.ZERO, 0.5)
|
||||
else:
|
||||
if highlighted:
|
||||
modulate = Color(1, 1, 1)
|
||||
wiggle_intensity = 1
|
||||
else:
|
||||
modulate = Color(1, 1, 1)
|
||||
wiggle_intensity = 0
|
||||
|
||||
@export var voice_line: AudioStream = null
|
||||
|
||||
func _ready() -> void:
|
||||
$Label.text = self.text
|
||||
$BackgroundSprite.frame = text.hash() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation)
|
||||
$Content/Label.text = self.text
|
||||
$Content/BackgroundSprite.frame = text.hash() % $Content/BackgroundSprite.sprite_frames.get_frame_count($Content/BackgroundSprite.animation)
|
||||
|
||||
|
||||
func replace_with(postit: PostIt):
|
||||
self.text = postit.text
|
||||
|
|
|
|||
|
|
@ -4,6 +4,10 @@
|
|||
[ext_resource type="Texture2D" uid="uid://c8ckkjmdegyis" path="res://logic-scenes/board/card-textures/postitsheet.png" id="2_j17jn"]
|
||||
[ext_resource type="Theme" uid="uid://b056fn288p8ha" path="res://logic-scenes/themes/messy.theme" id="3_hu2as"]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_ml4q7"]
|
||||
radius = 48.0
|
||||
height = 312.0
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_nj16s"]
|
||||
atlas = ExtResource("2_j17jn")
|
||||
region = Rect2(0, 0, 500, 220)
|
||||
|
|
@ -96,20 +100,25 @@ animations = [{
|
|||
"speed": 5.0
|
||||
}]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_ml4q7"]
|
||||
radius = 48.0
|
||||
height = 312.0
|
||||
|
||||
[node name="post-it" type="Area2D"]
|
||||
script = ExtResource("1_yvh5n")
|
||||
text = "Test"
|
||||
highlight_color = Color(1.2, 1.2, 1.2, 1)
|
||||
|
||||
[node name="BackgroundSprite" type="AnimatedSprite2D" parent="."]
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(99.5, 0)
|
||||
rotation = 1.5708
|
||||
shape = SubResource("CapsuleShape2D_ml4q7")
|
||||
|
||||
[node name="Content" type="Node2D" parent="."]
|
||||
|
||||
[node name="BackgroundSprite" type="AnimatedSprite2D" parent="Content"]
|
||||
position = Vector2(99.5, 0)
|
||||
scale = Vector2(0.65, 0.65)
|
||||
sprite_frames = SubResource("SpriteFrames_2amsi")
|
||||
frame = 5
|
||||
frame = 1
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
[node name="Label" type="Label" parent="Content"]
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
|
|
@ -123,10 +132,6 @@ grow_horizontal = 2
|
|||
grow_vertical = 2
|
||||
theme = ExtResource("3_hu2as")
|
||||
theme_type_variation = &"card_text"
|
||||
text = "Test"
|
||||
vertical_alignment = 1
|
||||
autowrap_mode = 3
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(99.5, 0)
|
||||
rotation = 1.5708
|
||||
shape = SubResource("CapsuleShape2D_ml4q7")
|
||||
|
|
|
|||
Loading…
Reference in New Issue