Page 1 of 1

Creating Custom Drawables?

Posted: Sun Sep 20, 2020 5:09 pm
by Ovidios
Hey!

Is there a way, in a regular LÖVE game, to create a new "Drawable" object, i.e. one that can be drawn using love.graphics.draw?
If so, how would I go about doing that?

Thanks!

Re: Creating Custom Drawables?

Posted: Sun Sep 20, 2020 5:14 pm
by ivan
Not without rebuilding Love2D. Drawable is a C++ thing so you can't create C++ object from Lua. FFI won't help you in this case.
In theory you could just replace the default love.graphics.draw function with your own but it's ugly and I wouldn't recommend it.

Re: Creating Custom Drawables?

Posted: Sun Sep 20, 2020 5:25 pm
by Ovidios
Mh alright...
Thank you anyway!

Re: Creating Custom Drawables?

Posted: Sun Sep 20, 2020 9:22 pm
by RNavega
Hi, what exactly are you trying to do, visually?

Re: Creating Custom Drawables?

Posted: Mon Sep 21, 2020 3:17 am
by zorg
If you want different shapes, then there are quite a few ways to make those (Polygons, Meshes); you don't need your own Drawable class.

Re: Creating Custom Drawables?

Posted: Mon Sep 21, 2020 4:39 am
by ivan
On an unrelated note, it would be cool if "Body" was "Drawable" for debug purposes.