From 4aa193064674235391d01991d63aa96b6adf0792 Mon Sep 17 00:00:00 2001 From: Adrian Schmid Date: Sun, 2 Jul 2023 11:01:04 +0200 Subject: [PATCH] reset rot./scale after removing post it from card --- src/logic-scenes/board/card-board.gd | 9 +++++++-- src/logic-scenes/board/post-it.gd | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/logic-scenes/board/card-board.gd b/src/logic-scenes/board/card-board.gd index c4334d57..a0771b23 100644 --- a/src/logic-scenes/board/card-board.gd +++ b/src/logic-scenes/board/card-board.gd @@ -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 area_dict["post_its_in_list"].erase(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: if is_in_dropzone(to_handle): 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.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 else: for panel in area_dict["post_it_panels"]: if panel.get_child_count() == 1: @@ -99,8 +102,10 @@ func handle_mouse_button(to_handle: Area2D, input: InputEvent): to_handle.set_owner(self) area_dict["dropzone_content"].erase(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.rotation = to_handle.base_rotation + to_handle.scale = to_handle.base_scale + reorder_areas("post_its_in_list") break currently_dragged_area = null diff --git a/src/logic-scenes/board/post-it.gd b/src/logic-scenes/board/post-it.gd index c808d39f..cd37efd5 100644 --- a/src/logic-scenes/board/post-it.gd +++ b/src/logic-scenes/board/post-it.gd @@ -46,11 +46,15 @@ var modulate_tween @export var voice_line: AudioStream = null @export var is_dragable: bool = false +var base_rotation = null +var base_scale = null var is_dragged = false func _ready() -> void: 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/BackgroundSprite.frame = text.hash() % $Content/BackgroundSprite.sprite_frames.get_frame_count($Content/BackgroundSprite.animation)