final changes for better touch function
This commit is contained in:
3
main.py
3
main.py
@@ -80,6 +80,7 @@ def touch(event):
|
|||||||
if event.type == pygame.FINGERDOWN and not touch_start:
|
if event.type == pygame.FINGERDOWN and not touch_start:
|
||||||
touch_start = (event.x * SCREEN_WIDTH, event.y * SCREEN_HEIGHT)
|
touch_start = (event.x * SCREEN_WIDTH, event.y * SCREEN_HEIGHT)
|
||||||
touch_start_time = time.time()
|
touch_start_time = time.time()
|
||||||
|
print("touch_start:")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
elif event.type == pygame.FINGERUP and touch_start:
|
elif event.type == pygame.FINGERUP and touch_start:
|
||||||
@@ -87,6 +88,7 @@ def touch(event):
|
|||||||
duration = time.time() - touch_start_time
|
duration = time.time() - touch_start_time
|
||||||
dx = end[0] - touch_start[0]
|
dx = end[0] - touch_start[0]
|
||||||
dy = end[1] - touch_start[1]
|
dy = end[1] - touch_start[1]
|
||||||
|
print("touch_end:")
|
||||||
print(f"Touch dx={dx}, dy={dy}, duration={duration}")
|
print(f"Touch dx={dx}, dy={dy}, duration={duration}")
|
||||||
|
|
||||||
touch_start = None
|
touch_start = None
|
||||||
@@ -99,6 +101,7 @@ def touch(event):
|
|||||||
elif dy < -50 and abs(dx) < 80 and duration > 0.3:
|
elif dy < -50 and abs(dx) < 80 and duration > 0.3:
|
||||||
return "ontop"
|
return "ontop"
|
||||||
else:
|
else:
|
||||||
|
print("touch_problem")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user