Page 1 of 1

Class structure using hardonCollider

Posted: Sat Oct 25, 2014 7:35 am
by reydefuego
I started on my first project with Love2d and lua, and for the collision detection I started by implementing it on my own but I decided to use hardoncollider instead. My question is right now I have three classes Sprite, Unit, Player: That's the hierarchy of the classes Sprite->Unit->Player and, judging by the tutorials, the collision object from hardoncollider has to be a base class? I was trying to do something like that, but I wasn't sure how to. I'm also using middleclass for the classes.

Re: Class structure using hardonCollider

Posted: Sat Oct 25, 2014 8:06 am
by bartbes
Because (iirc) you don't have objects, you have shapes. So in this case your entity would have a shape, not be one.

Re: Class structure using hardonCollider

Posted: Sat Oct 25, 2014 12:03 pm
by caldur
bartbes wrote:Because (iirc) you don't have objects, you have shapes. So in this case your entity would have a shape, not be one.
yep, and the thing that gives me a little headache is that you will have to route the collision info back to the owner of the shape...
so it's either implementing AABB and collision method on custome obejcts OR mannually add a reference field to the shape after it has been added to the collider... I am wondering if there is any alternative way to handle this more elegantly?

Re: Class structure using hardonCollider

Posted: Sun Oct 26, 2014 3:29 am
by reydefuego
I figured it out now, thanks bartbes.
so it's either implementing AABB and collision method on custome obejcts OR mannually add a reference field to the shape after it has been added to the collider... I am wondering if there is any alternative way to handle this more elegantly?
What I did was check what object was iterating over a table to find what the player was colliding with in the collision callback. Not the most elegant solution, but it works.