improving card and post it avoidance handling
This commit is contained in:
parent
a99433c73c
commit
12226e04f3
|
|
@ -98,7 +98,7 @@ func _process(delta: float) -> void:
|
|||
if area is Card or area is CardCollider:
|
||||
if area is CardCollider:
|
||||
position += area.direction * delta
|
||||
elif not area.highlighted:
|
||||
elif not area.highlighted or self.highlighted:
|
||||
var diff:Vector2 = position - area.position
|
||||
position -= diff.normalized() * ((diff.length()-diameter)/diameter) * bounce_speed * (delta/(1.0/60))
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,10 @@ var is_dragged: bool = false:
|
|||
|
||||
var mouse_offset: Vector2
|
||||
|
||||
@onready var diameter = $CollisionShape2D.shape.height
|
||||
@export_range(1.0, 10.0) var bounce_speed: float = 8
|
||||
var on_board = false
|
||||
|
||||
func _ready() -> void:
|
||||
|
||||
self.set_meta("type", "post-it") # set type information to find out if this node is a post-it
|
||||
|
|
@ -69,7 +73,16 @@ func replace_with(postit: PostIt):
|
|||
for group in postit.get_groups():
|
||||
self.add_to_group(group)
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
func _process(delta: float) -> void:
|
||||
if get_overlapping_areas().size() > 0 and is_dragable and on_board:
|
||||
for area in get_overlapping_areas():
|
||||
if area is Card or area is CardCollider:
|
||||
if area is CardCollider:
|
||||
position += area.direction * delta
|
||||
elif not area.highlighted or self.highlighted:
|
||||
var diff:Vector2 = position - area.position
|
||||
position -= diff.normalized() * ((diff.length()-diameter)/diameter) * bounce_speed * (delta/(1.0/60))
|
||||
|
||||
_move_post_it()
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue