scale when clicking on character

This commit is contained in:
Booklordofthedings 2024-08-18 12:09:28 +02:00
parent b0d6a99853
commit fb7a9c3852
2 changed files with 17 additions and 17 deletions

View file

@ -3,45 +3,45 @@ extends Node
@export var player : CharacterBody2D;
var current_selected = "none";
var this_frame = true;
@export var scale_duration: float = 0.5
var target_scale: Vector2 = Vector2(1, 1)
func _process(delta: float) -> void:
if Input.is_action_just_pressed("click") and this_frame:
func _unhandled_input(event: InputEvent) -> void:
if event.is_action_pressed("click"):
if current_selected == "scale_up":
scale_up()
elif current_selected == "scale_down":
scale_down()
elif current_selected == "mirror":
mirror();
this_frame = true
func select_up():
current_selected = "scale_up"
this_frame = false
func select_down():
current_selected = "scale_down"
this_frame = false
func select_mirror():
current_selected = "mirror"
this_frame = false
func scale_up():
if player:
target_scale = Vector2(3.0, 3.0)
var pPos = player.position
pPos.x += 1280/2
pPos.y += 720/2
if player.scale.x < 2 and get_viewport().get_mouse_position().distance_to(pPos) < 12:
target_scale = Vector2(2.0, 2.0)
start_scaling()
func scale_down():
if player:
target_scale = Vector2(0.5, 0.5)
var pPos = player.position
pPos.x += 1280/2
pPos.y += 720/2
if player.scale.x > 1 and get_viewport().get_mouse_position().distance_to(pPos) < 12:
target_scale = Vector2(1, 1)
start_scaling()
func start_scaling():