Reputation:
I'd like to know if there's a way to check if an object exists on a point, and if not, create a new one while snapping the new object to a grid? I know you can use this instance_create(x,y,obj_to_create);
but that just places on a point no matter what and doesn't snap to a grid. Also, is there a global mouse click event in Game Maker?
Thanks!
Upvotes: 0
Views: 2054
Reputation: 9445
well there are a few (almost similar) functions that allow you to do this... But most straight forward is to use position_meeting(x,y, obj)
so the could would become:
if (!position_meeting(x, y, obj_to_create)) {
instance_create(x,y,obj_to_create);
}
Now to snap to grid you'll have to create it at a snapped position:
instance_create(x div GRIDW, y div GRIDH, obj_to_create);
Upvotes: 1