korlibs / korlibs/korge

particleEmitter().onCollision() { } appears to have no effect upon object within closure

Open
#341 8 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Kotlin
Stars
3k
Forks
148
Avg merge
13h 44m
Merged PRs (30d)
1

Description

Actual behavior:

Running the following code with 2.0.7 runJvm, circle color change does not take place when circle object collides with any part of particleEmitter object.

```
val circle = circle(radius= 20.0, Colors.RED)

val emitter = resourcesVfs["./particle/particle.pex"].readParticleEmitter()

particleEmitter(emitter).position(views.virtualWidth * 0.5, views.virtualHeight * 0.75).onCollision( {it == circle}) {
circle.color = Colors.BLUE
}

circle.addUpdater {
circle.color = Colors.RED
x = mouseX - circle.radius
y = mouseY - circle.radius
}
```
code adapted from [KorGE Tutorial #5 Simple collision detection](https://www.youtube.com/watch?v=F1AXdD5bLjA) video and [korge-samples particle emitter](https://github.com/korlibs/korge-samples) code.

Expected behavior: Best case would be circle shape changes color when collision detected with base shape and particle flow. Next best case would be circle shape changes color when collision detected with base shape.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the supplied runJvm reproduction with particle/particle.pex, then compare it with the linked KorGE collision tutorial and particle-emitter sample. Trace particleEmitter(...).onCollision to determine which collision cases it handles; done means the callback changes the circle color for the documented base-shape or particle collision.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.