-
Is there a similar event like I’m guessing the way to do this would be on thanks in advance! kaboom is really cool! 🚀 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
You mean an event when an object stops colliding with another? Yeah the way to do it now would be in an But I think it's possible to support that built-in, since kaboom are also already doing some internal bookkeeping about if 2 collided objects are still colliding. |
Beta Was this translation helpful? Give feedback.
-
@pika11 -- In case it's helpful, I had to solve this problem today so I tried @slmjkdbtl's suggestion. This works: (I want to show elements when the "player" is standing in front of a "computer", but remove them after he's moved away.) export const computer = () => [
k.sprite("computer"),
k.area(),
{
add() {
this.onCollide("player", (p) => {
console.log("player hovering")
this.objColliding = p
})
this.onUpdate(() => {
if (!this.objColliding) return
if(!this.isColliding(this.objColliding)) {
console.log("player leaving")
this.objColliding = null
}
})
}
} |
Beta Was this translation helpful? Give feedback.
You mean an event when an object stops colliding with another?
Yeah the way to do it now would be in an
action
(which is deprecated in favor ofonUpdate
now) and check forisColliding()
\But I think it's possible to support that built-in, since kaboom are also already doing some internal bookkeeping about if 2 collided objects are still colliding.