place_meeting


描述

使用此函数,你可以使用运行检查代码的实例的碰撞遮罩检查与另一个实例或物体的所有实例的碰撞位置。当你使用它时,你实际上要求 GameMaker Studio 2 将实例移动到新位置,检查碰撞,然后向后移动并告诉你是否检测到了碰撞。这将适用于精确碰撞,但前提是选中的实例和物体都选择了精确碰撞遮罩,否则仅应用边界框碰撞。This function also accepts the special keywords all and other. Please note that should you need to get the unique instance id of the object being collided with, you should use instance_place.

Note that the given x/y coordinates will be floored to the nearest integer before the check is performed.


语法:

place_meeting(x, y, obj);

参数 描述
x The x position to check.
y The y position to check.
obj The instance or object to check for.


返回:

Boolean(布尔值)


例如:

if keyboard_check(vk_left)
   {
   if !place_meeting(x - 5, y, obj_wall) x -=5;
   }

The above code checks to see if there is not a collision to the left of the instance and moves the instance if there is none.