fixed checks for if post it is attached or if card has post it attached

This commit is contained in:
Adrian Schmid 2023-08-12 12:20:05 +02:00
parent d99b9edfdf
commit 5c487f55df
2 changed files with 5 additions and 9 deletions

View File

@ -52,6 +52,7 @@ var scale_tween
@export var voice_line: AudioStream = null
@export var is_dragable: bool = false
@onready var diameter = $CollisionShape2D.shape.height
@onready var postit_anchor = get_child(3)
var is_dragged: bool = false:
set(dragged):
@ -124,7 +125,7 @@ func _on_mouse_entered():
is_mouse_entered = true
if not Input.is_action_pressed("mouse_left"):
if has_postit_attached():
if get_child(-1).highlighted:
if postit_anchor.get_child(-1).highlighted:
return
highlighted = true
if "handle_hover" in owner:
@ -151,11 +152,7 @@ func _move_card():
position += (get_viewport().get_mouse_position() - position) - mouse_offset
func has_postit_attached() -> bool:
var all_children = get_children()
for child in all_children:
if child is PostIt:
return true
return false
return postit_anchor.get_child(-1) is PostIt
func check_hover():
if is_mouse_entered:

View File

@ -116,9 +116,8 @@ func _move_post_it():
position += (get_viewport().get_mouse_position() - position) - mouse_offset
func is_postit_attached() -> bool:
if self.get_parent() is Card:
return true
return false
# there is probably a nicer way to do this
return self.get_parent().get_parent() is Card
func tween_transform_to(target: Vector2):
var transform_tween = create_tween()