Class structure using hardonCollider
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 2
- Joined: Sat Oct 25, 2014 6:27 am
Class structure using hardonCollider
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.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Class structure using hardonCollider
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
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...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.
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?
-
- Prole
- Posts: 2
- Joined: Sat Oct 25, 2014 6:27 am
Re: Class structure using hardonCollider
I figured it out now, thanks bartbes.
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.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?
Who is online
Users browsing this forum: No registered users and 16 guests