reset rot./scale after removing post it from card

This commit is contained in:
Adrian Schmid 2023-07-02 11:01:04 +02:00
parent 72825ecae6
commit 0c8e3557ae
2 changed files with 11 additions and 2 deletions

View File

@ -82,7 +82,7 @@ func handle_mouse_button(to_handle: Area2D, input: InputEvent):
to_handle.set_owner(self) # needs to be here otherwise the owner disappears to_handle.set_owner(self) # needs to be here otherwise the owner disappears
area_dict["post_its_in_list"].erase(to_handle) area_dict["post_its_in_list"].erase(to_handle)
area_dict["dropzone_content"].push_back(to_handle) area_dict["dropzone_content"].push_back(to_handle)
# TODO: Add function to rearrange the array based on positions in the dropzone # TODO (if needed): Add function to rearrange the array based on positions in the dropzone
else: else:
if is_in_dropzone(to_handle): if is_in_dropzone(to_handle):
if to_handle.has_overlapping_areas(): if to_handle.has_overlapping_areas():
@ -92,6 +92,9 @@ func handle_mouse_button(to_handle: Area2D, input: InputEvent):
to_handle.reparent(area) to_handle.reparent(area)
to_handle.set_owner(self) to_handle.set_owner(self)
to_handle.position = area.get_child(3).position to_handle.position = area.get_child(3).position
else:
to_handle.rotation = to_handle.base_rotation
to_handle.scale = to_handle.base_scale
else: else:
for panel in area_dict["post_it_panels"]: for panel in area_dict["post_it_panels"]:
if panel.get_child_count() == 1: if panel.get_child_count() == 1:
@ -99,8 +102,10 @@ func handle_mouse_button(to_handle: Area2D, input: InputEvent):
to_handle.set_owner(self) to_handle.set_owner(self)
area_dict["dropzone_content"].erase(to_handle) area_dict["dropzone_content"].erase(to_handle)
area_dict["post_its_in_list"].push_back(to_handle) area_dict["post_its_in_list"].push_back(to_handle)
# TODO: Add function to rearrange the array based on taken panel spot
to_handle.position = panel.get_child(0).position to_handle.position = panel.get_child(0).position
to_handle.rotation = to_handle.base_rotation
to_handle.scale = to_handle.base_scale
reorder_areas("post_its_in_list")
break break
currently_dragged_area = null currently_dragged_area = null

View File

@ -46,11 +46,15 @@ var modulate_tween
@export var voice_line: AudioStream = null @export var voice_line: AudioStream = null
@export var is_dragable: bool = false @export var is_dragable: bool = false
var base_rotation = null
var base_scale = null
var is_dragged = false var is_dragged = false
func _ready() -> void: func _ready() -> void:
self.set_meta("type", "post-it") # set type information to find out if this node is a post-it self.set_meta("type", "post-it") # set type information to find out if this node is a post-it
base_rotation = rotation
base_scale = scale
$Content/Label.text = self.text $Content/Label.text = self.text
$Content/BackgroundSprite.frame = text.hash() % $Content/BackgroundSprite.sprite_frames.get_frame_count($Content/BackgroundSprite.animation) $Content/BackgroundSprite.frame = text.hash() % $Content/BackgroundSprite.sprite_frames.get_frame_count($Content/BackgroundSprite.animation)