I need to perform animation on collision: ```box.o...
# korge
v
I need to perform animation on collision:
Copy code
box.onCollision {
  view.tween(...)
}
How do I pass the coroutine context there? Is there something like
box.onCollisionSuspended {..}
?
Copy code
launchImmediately(Dispatchers.Default) {
works, I guess
d
You shouldn't use
Dispatchers.Default
since KorGE has its own dispatcher, and that would use a different thread and you might have issues on some targets, you should propagate the coroutineContext of either the views, or a scene (that would handle its lifecycle)
v
Could you give me an example of how would I access the
views
singleton from a random place in the program?
d
You can't. You have to propagate views, or an instance containing views. For example scenes contain views. If you have a suspend function, you can access the vies with
views()
the coroutine context if propagated properly should have the injector referenced