How would you go about getting the angle() between two instances of the same object when they overlap? I'm having difficulty isolating each of them. I want it so that when they overlap, they are moved a couple pixels directly away from each other. I figured that if I get the angle() between them and move one in a positive and the other in a negative direction, that will separate them.
This is easier with Families, but without, you need to Pick the first, cache it's X,Y, then Pick the second, get the angle, calculate the two angles, change Two, go back and Pick One, and set it's angle.
blackhornet Weeellll, it turns out the two objects in question are mobs in the same family. How does that change things?
Families let you reference the same object separately. Just make a duplicate of the family, in this case, and use the duplicate for collision detection. Two lines of code instead of 9.
Develop games in your browser. Powerful, performant & highly capable.
blackhornet Hmmm, so if the same sprite is in two different families, and an instance of the sprite collides with another instance of the same sprite, it will trigger an event as a collision between a member of family A and family B? I loaded up your double family example and maybe I'm reading it wrong, but it seems to show a collision between two *different* objects from the same family? I will experiment a little...
blackhornet Oh, I see what you did. I hadn't looked at the first example, so I was confused by it's presence in this example, plus the two different animation frames for the same sprite. I get it now, so like I said in the above post. That's awesome, and much simpler. Thank you Blackhornet!