generalise card so card contents can be replaced without the need for re-parenting
This commit is contained in:
parent
5cda8233fd
commit
0f75bd1dd3
|
|
@ -9,6 +9,7 @@ var own_postits: Array[PostIt] = []
|
|||
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)
|
||||
text = value
|
||||
@export var voice_line: AudioStream = null
|
||||
|
||||
|
|
@ -22,12 +23,22 @@ func _ready():
|
|||
|
||||
compatible_postits.append_array(own_postits)
|
||||
|
||||
if own_postits.size() == 2:
|
||||
own_postits[0].sibling = own_postits[1]
|
||||
own_postits[1].sibling = own_postits[0]
|
||||
|
||||
$BackgroundSprite.frame = randi() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation)
|
||||
$Label.text = self.text
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
func replace_with(card: Card):
|
||||
self.text = card.text
|
||||
self.compatible_postits = card.compatible_postits
|
||||
self.own_postits = card.own_postits
|
||||
self.voice_line = card.voice_line
|
||||
|
||||
func _on_focus_entered():
|
||||
print(self, "is focused")
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
extends Control
|
||||
class_name PostIt
|
||||
var sibling
|
||||
|
||||
@export var text: String = "" :
|
||||
set (value):
|
||||
|
|
@ -15,6 +16,11 @@ func _ready() -> void:
|
|||
$Label.text = self.text
|
||||
$BackgroundSprite.frame = text.hash() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation)
|
||||
|
||||
func replace_with(postit: PostIt):
|
||||
self.text = postit.text
|
||||
self.voice_line = postit.voice_line
|
||||
self.sibling = postit.sibling
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue