Draw Collider shape?

30 views
Skip to first unread message

Thomer Gil

unread,
Apr 30, 2020, 7:03:37 PM4/30/20
to excaliburjs
Is there an easy way to draw actor.body.collider.shape of some or all actors? I see there's a Physics.showBounds, but I'm probably using it wrong. Thank you.

DaVince

unread,
May 1, 2020, 6:58:58 AM5/1/20
to excaliburjs
This feels like a bug to me, unless I'm also misinterpreting the intended use of Physics.showBounds.

However, if you set the isDebug property on your Engine instance to true, it'll show you all of the bounding boxes (and more).

Op vrijdag 1 mei 2020 01:03:37 UTC+2 schreef Thomer Gil:

Erik Onarheim

unread,
May 1, 2020, 8:26:03 AM5/1/20
to excaliburjs
Hi Thomer & DaVince,

Currently if an actor has no current drawing set, the collider's shape will be drawn. Originally when this was built it was thought people would use drawings or shapes but not both at the same time for an Actor, let me know your thoughts.

this.body.collider.shape.draw(ctx, this.color, new Vector(this.width * this.anchor.x, this.height * this.anchor.y));

The onPostDraw() could be overridden right now to do more robust shape drawing in addition to sprites/animations.

Cheers,
Erik

DaVince

unread,
May 1, 2020, 8:59:24 AM5/1/20
to excaliburjs
Oh, that makes a lot of sense. I actually do just draw actors as solid colors in some tests, but I didn't realize that the color fill is based on the actor's collider's shape.

Regardless, the method "showBounds" is named such that it gives the impression that it will specifically render an outline of the bounds for you. I misinterpreted the question as "I need to draw them for debug purposes".
Reply all
Reply to author
Forward
0 new messages