本文整理汇总了C#中CocosSharp.CCPhysicsBody.AddShape方法的典型用法代码示例。如果您正苦于以下问题:C# CCPhysicsBody.AddShape方法的具体用法?C# CCPhysicsBody.AddShape怎么用?C# CCPhysicsBody.AddShape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CocosSharp.CCPhysicsBody
的用法示例。
在下文中一共展示了CCPhysicsBody.AddShape方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateEdgeBox
/** Create a body contains a EdgeBox shape. */
public static CCPhysicsBody CreateEdgeBox(CCSize size, CCPhysicsMaterial material, float border, CCPoint offset)
{
CCPhysicsBody body = new CCPhysicsBody();
body.AddShape(new CCPhysicsShapeEdgeBox(size, material, offset, border));
body.IsDynamic = false;
return body;
}
示例2: CreateEdgeChain
/** Create a body contains a EdgeChain shape. */
public static CCPhysicsBody CreateEdgeChain(CCPoint[] points, int count, CCPhysicsMaterial material, float border = 1)
{
CCPhysicsBody body = new CCPhysicsBody();
body.AddShape(new CCPhysicsShapeEdgeChain(points, count, material, border));
body.IsDynamic = false;
return body;
}
示例3: CreatePolygon
/**
* @brief Create a body contains a polygon shape.
* points is an array of cpVect structs defining a convex hull with a clockwise winding.
*/
public static CCPhysicsBody CreatePolygon(CCPoint[] points, int count, CCPhysicsMaterial material, float radius)
{
CCPhysicsBody body = new CCPhysicsBody();
body.AddShape(new CCPhysicsShapePolygon(points, count, material, radius));
return body;
}
示例4: CreateEdgeSegment
/** Create a body contains a EdgeSegment shape. */
public static CCPhysicsBody CreateEdgeSegment(CCPoint a, CCPoint b, CCPhysicsMaterial material, float border = 1)
{
CCPhysicsBody body = new CCPhysicsBody();
body.AddShape(new CCPhysicsShapeEdgeSegment(a, b, material, border));
body.IsDynamic = false;
return body;
}
示例5: CreateCircle
/** Create a body contains a circle shape. */
public static CCPhysicsBody CreateCircle(float radius, CCPhysicsMaterial material, CCPoint offset)
{
CCPhysicsBody body = new CCPhysicsBody();
body.AddShape(new CCPhysicsShapeCircle(material, radius, offset));
return body;
}
示例6: CreateBox
/** Create a body contains a box shape. */
public static CCPhysicsBody CreateBox(CCSize size, CCPhysicsMaterial material, float radius)
{
CCPhysicsBody body = new CCPhysicsBody();
body.AddShape(new CCPhysicsShapeBox(size, material, radius));
return body;
}
示例7: OnEnter
public override void OnEnter()
{
base.OnEnter();
float width = (VisibleBoundsWorldspace.Size.Width - 10) / 4;
float height = (VisibleBoundsWorldspace.Size.Height - 50) / 4;
Scene.PhysicsWorld.DebugDrawMask = PhysicsDrawFlags.Shapes | PhysicsDrawFlags.Joints;
CCNode node = new CCNode();
CCPhysicsBody box = new CCPhysicsBody();
node.PhysicsBody = box;
box.IsDynamic = false;
node.Position = CCPoint.Zero;
AddChild(node);
CCPhysicsJoint joint;
CCSprite sp1, sp2;
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
CCPoint offset = new CCPoint(
0 + 5 + j * width + width / 2,
0 + 50 + i * height + height / 2
);
//CCPoint offset = new CCPoint()
box.AddShape(
new CCPhysicsShapeEdgeBox(
new CCSize(width, height), CCPhysicsMaterial.PHYSICSSHAPE_MATERIAL_DEFAULT,
offset, 1)
);
switch (i * 4 + j)
{
case 0:
sp1 = MakeBall(offset - new CCPoint(30, 0), 10);
sp1.PhysicsBody.Tag = DRAG_BODYS_TAG;
sp2 = MakeBall(offset + new CCPoint(30, 0), 10);
sp2.PhysicsBody.Tag = DRAG_BODYS_TAG;
joint = CCPhysicsJointPin.Construct(sp1.PhysicsBody, sp2.PhysicsBody, offset);
Scene.PhysicsWorld.AddJoint(joint);
AddChild(sp1);
AddChild(sp2);
break;
case 1:
sp1 = MakeBall(offset - new CCPoint(30, 0), 10);
sp1.PhysicsBody.Tag = DRAG_BODYS_TAG;
sp2 = MakeBox(offset + new CCPoint(30, 0), new CCSize(30, 10));
sp2.PhysicsBody.Tag = DRAG_BODYS_TAG;
joint = CCPhysicsJointFixed.Construct(sp1.PhysicsBody, sp2.PhysicsBody, offset);
Scene.PhysicsWorld.AddJoint(joint);
AddChild(sp1);
AddChild(sp2);
break;
case 2:
sp1 = MakeBall(offset - new CCPoint(30, 0), 10);
sp1.PhysicsBody.Tag = DRAG_BODYS_TAG;
sp2 = MakeBox(offset + new CCPoint(30, 0), new CCSize(30, 10));
sp2.PhysicsBody.Tag = DRAG_BODYS_TAG;
joint = CCPhysicsJointDistance.Construct(sp1.PhysicsBody, sp2.PhysicsBody, CCPoint.Zero, CCPoint.Zero);
Scene.PhysicsWorld.AddJoint(joint);
AddChild(sp1);
AddChild(sp2);
break;
case 3:
sp1 = MakeBall(offset - new CCPoint(30, 0), 10);
sp1.PhysicsBody.Tag = DRAG_BODYS_TAG;
sp2 = MakeBox(offset + new CCPoint(30, 0), new CCSize(30, 10));
sp2.PhysicsBody.Tag = DRAG_BODYS_TAG;
joint =
CCPhysicsJointSpring.Construct(sp1.PhysicsBody,
sp2.PhysicsBody, CCPoint.Zero, CCPoint.Zero, 500, 0.3f);
Scene.PhysicsWorld.AddJoint(joint);
AddChild(sp1);
AddChild(sp2);
//.........这里部分代码省略.........
示例8: CreateEdgePolygon
/** Create a body contains a EdgePolygon shape. */
public static CCPhysicsBody CreateEdgePolygon(cpVect[] points, int count, CCPhysicsMaterial material, float border = 1)
{
CCPhysicsBody body = new CCPhysicsBody();
body.AddShape(new CCPhysicsShapeEdgePolygon(points, count, material, border));
body._dynamic = false;
return body;
}
示例9: CreateCircle
/** Create a body contains a circle shape. */
public static CCPhysicsBody CreateCircle(float radius, CCPhysicsMaterial material, cpVect offset)
{
CCPhysicsBody body = new CCPhysicsBody();
body.SetMass(MASS_DEFAULT);
body.AddShape(new CCPhysicsShapeCircle(material, radius, offset));
return body;
}
示例10: j2cpBody
public CCPhysicsBody j2cpBody( JObject bodyValue)
{
CCPhysicsBody body = new CCPhysicsBody();
SetBodyTypeFromInt(body, (int)bodyValue.GetValue("type"));
//int i = 0;
JArray fixtureValues = (JArray)bodyValue["fixture"];
if (null != fixtureValues)
{
List<CCPhysicsShape> shape;
int numFixtureValues = fixtureValues.Count;
for (int i = 0; i < numFixtureValues; i++)
{
JObject fixtureValue = (JObject)fixtureValues[i];
shape = j2cpShape(fixtureValue, body.BodyType);
readCustomPropertiesFromJson(shape, fixtureValue);
body.AddShape(shape,true);
}
}
body.Position = jsonToPoint("position", bodyValue);
body.SetAngle(jsonToFloat("angle", bodyValue));
body.SetVelocity(jsonToPoint("linearVelocity", bodyValue));
body.SetAngularVelocity( jsonToFloat("angularVelocity", bodyValue));
//body. linearDamping = jsonToFloat("linearDamping", bodyValue, -1, 0);
//body.set angularDamping = jsonToFloat("angularDamping", bodyValue, -1, 0);
//body.gravityScale = jsonToFloat("gravityScale", bodyValue, -1, 1);
//body.allowSleep = bodyValue["allowSleep"] == null ? false : (bool)bodyValue["allowSleep"];
//body.awake =;
var awake = bodyValue["awake"] == null ? false : (bool)bodyValue["awake"];
if (!awake)
body.Body.Sleep();
var fixedRotation = bodyValue["fixedRotation"] == null ? false : (bool)bodyValue["fixedRotation"];
if (fixedRotation)
body.Moment = cp.Infinity;
//body.bullet = bodyValue["bullet"] == null ? false : (bool)bodyValue["bullet"];
//bodyDef.active = bodyValue["active"] == null ? false : (bool)bodyValue["active"];
//body.active = true;
String bodyName = bodyValue["name"] == null ? "" : (string)bodyValue["active"];
if (!string.IsNullOrEmpty(bodyName))
SetBodyName(body, bodyName);
// may be necessary if user has overridden mass characteristics
//b2MassData massData = new b2MassData();
if (body.BodyType == cpBodyType.DYNAMIC)
body.Body.SetMass(jsonToFloat("massData-mass", bodyValue));
//massData.mass = ;
body.Body.SetCenterOfGravity(jsonToVec("massData-center", bodyValue));
//massData.center =;
return body;
}