Hi, i tried many aproaches and I am stuck in a simple thing. When I collide with an object he spawns in other place and sometimes he just repeats, at the beginning i thought when colliding the object could being spawning in the same place so it would count as collide again and add, but he is doing double points and i dont know why. Ilucidate me please.
My point is repeating the function in case the object spawns in the player or in the layers obstaculos and areia, so if the x and y are the same he repeats the function to find another x and y, if i take it off the objects will start deseapiring eventually right? Even like this e continues adding 2 or 3 instead of 1:
It works like this, but he still add more than 1 to the objects, and i have no idea, is like a bug and counts 2 instead of one, i made the console log count for me, so i know he is getting one by one, is like the function repeats it self.
So from begginning, I create an object group with 100 objects each one with a random x and y and random sprites, then if i colide my player with one of this objects I do an overlap of the x and y so the object I have collided spawns in a diferent area calling the function colision objects.
Then to not allowing the object to spawn in no-area or above the player i do:
Create two random x and y, do verification if those are in the player x and y +200(area) if is in that area make the function again to find another x and y. if is not in that area proceed, the same for the layers. I dont understand why he is adding 2 ,3, 4 or 5+, when he only can make the if once.