I have two objects that appear randomly on stage, but i want them to never touch each other when they appear.
object1.x = Math.random() * stage.stageWidth;
object1.y = Math.random() * stage.stageHeight;
object2.x = Math.random() * stage.stageWidth;
object2.y = Math.random() * stage.stageHeight;
As @DodgerThud has mentioned; the way to go about this problem is to repeatedly attempt to place the next object until it meets your criteria (not colliding with another object). This is a perfect example of what a
whileloop can be used for, something like: