ํ‚ค๋ณด๋“œ๋‚˜ ๋งˆ์šฐ์Šค๋Š” Input.is_action_just_pressed() ํ•จ์ˆ˜๋ฅผ ํ†ตํ•ด์„œ


ํด๋ฆญ๋œ ์ฒซ ์ˆœ๊ฐ„์„ ํฌ์ฐฉํ•  ์ˆ˜ ์žˆ์ž–์•„.


๊ทผ๋ฐ, ๋ชจ๋ฐ”์ผ ํ„ฐ์น˜๋ฅผ ๊ฐ์ง€ํ•˜๊ธฐ ์œ„ํ•ด์„œ InputEvent ๊ฐ์ฒด๋ฅผ ์ด์šฉํ•˜๋ ค๋Š”๋ฐ, ์—ฌ๊ธด just_pressed๊ฐ€ ์—†๋„ค..


a16711aa372a76ac7eb8f68b12d21a1d5093f632f2


a16711aa372a6ae864afd19528d52703df793a7e764f


์บก์ฒ˜๋ฅผ ๋ณด๋ฉด ์•Œ๊ฒ ์ง€๋งŒ ๋นจ๊ฐ„ ๋™๊ทธ๋ผ๋ฏธ ์นœ ๋†ˆ์„ ๋“œ๋ž˜๊ทธํ•ด์„œ ์›€์ง์ด๋ฉด, ๋‹ค๋ฅธ ๋†ˆ๋“ค๋„ ๋“œ๋ž˜๊ทธ์— ๋ฐ˜์‘ํ•ด์„œ ํ•ฉ์ณ์ ธ ๋ฒ„๋ฆผ;


๋งŒ์•ฝ just_pressed ๋ฉ”์†Œ๋“œ๊ฐ€ ์žˆ์œผ๋ฉด ์•„์ฃผ ์‰ฝ๊ฒŒ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๋Š”๋ฐ ๋ง์ด์ง€.





๋ฌผ๋ก  ๋Œ€์•ˆ์ฑ…์œผ๋กœ ํ˜„์žฌ ๋“œ๋ž˜๊ทธํ•˜๋Š” ์ค‘์ธ์ง€๋ฅผ ์ฒดํฌํ•˜๋Š” ์‹์œผ๋กœ (์˜ˆ๋ฅผ ๋“ค์–ด ์–ด๋–ค ๋งˆ๋ฒ•์‚ฌ ๊ฐ์ฒด๊ฐ€ ๋“œ๋ž˜๊ทธ ๋  ๋•Œ ๊ทธ ์ •๋ณด๋ฅผ ์–ด๋”˜๊ฐ€ ์ €์žฅํ•ด๋†“๋Š” ๊ฑฐ์ง€)

ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๊ธด ํ•œ๋ฐ, touch input์— ๋Œ€ํ•œ just_pressed๊ฐ€ ์ •๋ง ์—†๋Š” ๊ฑด์ง€ ๊ถ๊ธˆํ•จ. ๋งŒ์•ฝ ์—†๋‹ค๊ณ  ํ•˜๋ฉด ๊ทธ๋ƒฅ ์œ„์ฒ˜๋Ÿผ ์ฃผ๋จน๊ตฌ๊ตฌ์‹์œผ๋กœ ํ•ด๊ฒฐํ•  ์ˆ˜๋ฐ–์— ์—†๋Š” ๊ฑฐ์ž„?




์ถ”๊ฐ€)



func _on_area_2d_input_event(viewport, event, shape_idx):

ย  ย  if event is InputEventScreenTouch:

# ๊ทผ๋ฐ ์—ฌ๊ธด just_pressed ํ•จ์ˆ˜๊ฐ€ ์—†์Œ..

if event.is_pressed():

before = position

modulate.a = 0.3

else:

position = Vector2(snapped(position.x - 32, 64) + 32, snapped(position.y -32, 64) + 32)

modulate.a = 1

if not can_drop():

position = before

if event is InputEventScreenDrag:

position = get_global_mouse_position()