本文整理汇总了C#中CocosSharp.CCPhysicsBody.GetWorld方法的典型用法代码示例。如果您正苦于以下问题:C# CCPhysicsBody.GetWorld方法的具体用法?C# CCPhysicsBody.GetWorld怎么用?C# CCPhysicsBody.GetWorld使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CocosSharp.CCPhysicsBody
的用法示例。
在下文中一共展示了CCPhysicsBody.GetWorld方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddBody
public virtual CCPhysicsBody AddBody(CCPhysicsBody body)
{
cp.AssertWarn(body != null, "the body can not be nullptr");
if (body.GetWorld() == this)
return null;
if (body.GetWorld() != null)
{
body.RemoveFromWorld();
}
AddBodyOrDelay(body);
_bodies.Add(body);
body._world = this;
return body;
}
示例2: RemoveBody
/** Remove a body from physics world. */
public virtual void RemoveBody(CCPhysicsBody body)
{
if (body.GetWorld() != this)
{
cp.AssertWarn("Physics Warnning: this body doesn't belong to this world");
return;
}
// destory the body's joints
foreach (var joint in body._joints)
{
// set destroy param to false to keep the iterator available
RemoveJoint(joint, false);
CCPhysicsBody other = (joint.GetBodyA() == body ? joint.GetBodyB() : joint.GetBodyA());
other.RemoveJoint(joint);
if (_delayRemoveJoints.Exists(j => j == joint))
joint._destoryMark = true;
}
body._joints.Clear();
RemoveBodyOrDelay(body);
_bodies.Remove(body);
body._world = null;
}