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):
|
set (value):
|
||||||
if is_inside_tree() or Engine.is_editor_hint():
|
if is_inside_tree() or Engine.is_editor_hint():
|
||||||
$Label.text = value
|
$Label.text = value
|
||||||
|
$BackgroundSprite.frame = text.hash() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation)
|
||||||
text = value
|
text = value
|
||||||
@export var voice_line: AudioStream = null
|
@export var voice_line: AudioStream = null
|
||||||
|
|
||||||
|
|
@ -22,12 +23,22 @@ func _ready():
|
||||||
|
|
||||||
compatible_postits.append_array(own_postits)
|
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)
|
$BackgroundSprite.frame = randi() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation)
|
||||||
$Label.text = self.text
|
$Label.text = self.text
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
pass
|
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():
|
func _on_focus_entered():
|
||||||
print(self, "is focused")
|
print(self, "is focused")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
extends Control
|
extends Control
|
||||||
class_name PostIt
|
class_name PostIt
|
||||||
|
var sibling
|
||||||
|
|
||||||
@export var text: String = "" :
|
@export var text: String = "" :
|
||||||
set (value):
|
set (value):
|
||||||
|
|
@ -15,6 +16,11 @@ func _ready() -> void:
|
||||||
$Label.text = self.text
|
$Label.text = self.text
|
||||||
$BackgroundSprite.frame = text.hash() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation)
|
$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:
|
func _process(delta: float) -> void:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue