1
I have in a project a class Collision
, and to make detection more efficient, wanted to have access to all instances (objects) of that same class. Is there any easy way to do this?
Edit 1
I did this: I created a class called world
, which stores all objects and collisions, where I have the method isColliding
, which checks the collision between an object and all other objects, or between two objects.
You can save an entire class instance array right away by creating the new object in the constructor and removing it from the vector by deconstructing the object. Be aware who compare all instantiated objects may not be the best solution, this alternative solution you proposed is correct, but it can cost a lot of processing and slow down the game
– Jefferson Quesado
I thought of something of this suit. A container
static
(e. g.,vector
,set
,map
orunordered_set
) with pointers for each instance. Constructors and destructors respectively add or remove elements from the collection.– Anthony Accioly
Post as response.
– Maniero
@Jeffersonquesado , if I do not check with all objects, as I will analyze the collision?
– Felipe Nascimento
@moustache typing on mobile is costly. I’m with another issue in draft, ending that I go back to that
– Jefferson Quesado
@Felipebirth segmentation by position/classes of Apollo; Mario’s red turtles don’t need to know they have ground, they only move between fixed points, so we don’t need to bump them into the ground. In the future answer I will go into more detail
– Jefferson Quesado