physics_joint_delete

从物理世界中删除关节

语法:

physics_joint_delete(joint)


参数 描述
joint 你要删除的关节索引


返回: N/A(无返回值)


描述

Once two instances with physics representations have been bound by a joint, this can be deleted again at any time. Normally this will happen automatically when one of the two instances is destroyed, or when the room ends, but there are times when you may wish to do this manually. In those cases you would use this function.

It should also be noted that whenever an instance that is part of a gear joint is destroyed, the gear joint should be deleted using this function before any of the instances involved in forming the gear (but the remaining joints will be deleted automatically), for example in the destroy event of the instance.


例如:

var reactionForceX, reactionForceY, reactionForce;
if shipJoint
   {
   reactionForceX = physics_joint_get_value(shipJoint, phy_joint_reaction_force_x);
   reactionForceY = physics_joint_get_value(shipJoint, phy_joint_reaction_force_x);
   reactionForce = sqrt((reactionForceX + reactionForceX) + (reactionForceY + reactionForceY));
   if reactionForce > 2
      {
      physics_joint_delete(shipJoint);
      shipJoint = -1;
      }
   }

The above code checks to see if the variable "shipJoint" holds a joint index and if it does, it then calculates the force being applied to that joint using the two constants. 最后,如果关节合力大于2,则该关节会删除失效。


上一页:关节
下一页:physics_joint_enable_motor
© Copyright YoYo Games Ltd. 2018 All Rights Reserved