prevent putting multiple post its on one card

This commit is contained in:
Adrian Schmid 2023-07-02 11:50:19 +02:00
parent 0c8e3557ae
commit 4be0471018
2 changed files with 13 additions and 4 deletions

View File

@ -89,9 +89,10 @@ func handle_mouse_button(to_handle: Area2D, input: InputEvent):
var overlaps = to_handle.get_overlapping_areas()
for area in overlaps:
if area.get_meta("type") == "card":
to_handle.reparent(area)
to_handle.set_owner(self)
to_handle.position = area.get_child(3).position
if !area.has_postit_attached():
to_handle.reparent(area)
to_handle.set_owner(self)
to_handle.position = area.get_child(3).position
else:
to_handle.rotation = to_handle.base_rotation
to_handle.scale = to_handle.base_scale
@ -127,5 +128,5 @@ func reorder_areas(reorder: String):
i += 1
new_order.insert(i, obj)
print_debug(new_order)
#print_debug(new_order)

View File

@ -118,3 +118,11 @@ func _on_input_event(viewport, event, shape_idx):
func _move_card():
if is_dragged:
position += get_viewport().get_mouse_position() - position
func has_postit_attached() -> bool:
var all_children = get_children()
print_debug(all_children)
for child in all_children:
if child.get_meta("type") == "post-it":
return true
return false