From cf06b209e1958bb80d68886294447a11e317b6b1 Mon Sep 17 00:00:00 2001 From: koen1711 Date: Sat, 7 Dec 2024 11:57:24 +0100 Subject: [PATCH 1/2] fix: multiple sprites in when_touching doesn't work --- play/objects/sprite.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/play/objects/sprite.py b/play/objects/sprite.py index e11e13e..a088f4d 100644 --- a/play/objects/sprite.py +++ b/play/objects/sprite.py @@ -422,20 +422,20 @@ def decorator(func): async_callback = _make_async(func) async def wrapper(): - wrapper.is_running = True await run_async_callback( async_callback, [], [], ) - wrapper.is_running = False - wrapper.is_running = False for sprite in sprites: + async def wrapper_func(): + await wrapper() + sprite._dependent_sprites.append(self) callback_manager.add_callback( - CallbackType.WHEN_TOUCHING, (wrapper, sprite), id(self) + CallbackType.WHEN_TOUCHING, (wrapper_func, sprite), id(self) ) return wrapper From 637dc5e232237c31d1bcf3996832f9ce21e10062 Mon Sep 17 00:00:00 2001 From: koen1711 Date: Sat, 7 Dec 2024 11:59:07 +0100 Subject: [PATCH 2/2] chore: run black --- play/objects/sprite.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/play/objects/sprite.py b/play/objects/sprite.py index a088f4d..06672fd 100644 --- a/play/objects/sprite.py +++ b/play/objects/sprite.py @@ -428,8 +428,8 @@ async def wrapper(): [], ) - for sprite in sprites: + async def wrapper_func(): await wrapper()