本文整理汇总了C#中CocosSharp.CCPhysicsBody.SetVelocity方法的典型用法代码示例。如果您正苦于以下问题:C# CCPhysicsBody.SetVelocity方法的具体用法?C# CCPhysicsBody.SetVelocity怎么用?C# CCPhysicsBody.SetVelocity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CocosSharp.CCPhysicsBody
的用法示例。
在下文中一共展示了CCPhysicsBody.SetVelocity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}