I'm trying to do something like a level editor. I want to prevent solid objects to be stacked on top of each other. I have a condition that checks if there is an overlap - in that case, the solid objects can't be placed in the level.
But it seems I'm lacking the skill to write a condition that checks if the overlapping has stopped. I tried several versions with boolean variables and without. The stopping condition seems to fire every tick. I created a simplified version attached below (there are several hundred placeable objects in the original project, so this should really work with families). Can anyone point out to me how the condition can be fixed?
Develop games in your browser. Powerful, performant & highly capable.
Took me a while to understand your code, and the fact that all objects are named "Sprite" didn't help :)
Here is the fixed version, I used drag&drop behavior and a clone family:
When you drop the object and it's overlapping another object, instead of destroying it you can return it to its previous location. Use a pair of instance variables to store previous x and y.
Thanks man, the clone family is a nice workaround! I'm trying to create more of a stamp system than a drag&drop one (my capex didn't indicate that, sorry) - but it should work with the clone family. Thanks again!