当前位置: 首页>>代码示例>>C#>>正文


C# CCPhysicsBody.SetVelocity方法代码示例

本文整理汇总了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;
        }
开发者ID:netonjm,项目名称:RubeLoader,代码行数:58,代码来源:Nb2dJson.cs


注:本文中的CocosSharp.CCPhysicsBody.SetVelocity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。