• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# CocosSharp.CCPhysicsBody类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中CocosSharp.CCPhysicsBody的典型用法代码示例。如果您正苦于以下问题:C# CCPhysicsBody类的具体用法?C# CCPhysicsBody怎么用?C# CCPhysicsBody使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CCPhysicsBody类属于CocosSharp命名空间,在下文中一共展示了CCPhysicsBody类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Construct

		public static CCPhysicsJointRatchet Construct(CCPhysicsBody a, CCPhysicsBody b, float phase, float ratchet)
		{
			CCPhysicsJointRatchet joint = new CCPhysicsJointRatchet();

			if (joint != null && joint.Init(a, b, phase, ratchet))
			{
				return joint;
			}

			return null;
		}
开发者ID:kkarol93,项目名称:CocosSharp,代码行数:11,代码来源:CCPhysicsJoint.cs


示例2: 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;
		}
开发者ID:h7ing,项目名称:CocosSharp,代码行数:8,代码来源:CCPhysicsBody.cs


示例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;
		}
开发者ID:h7ing,项目名称:CocosSharp,代码行数:11,代码来源:CCPhysicsBody.cs


示例4: 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;
		}
开发者ID:h7ing,项目名称:CocosSharp,代码行数:7,代码来源:CCPhysicsBody.cs


示例5: SetCustomString

 public void SetCustomString(CCPhysicsBody item, String propertyName, String val)
 {
     m_bodiesWithCustomProperties.Add(item);
     GetCustomPropertiesForItem(item, true).m_customPropertyMap_string.Add(propertyName, val);
 }
开发者ID:netonjm,项目名称:RubeLoader,代码行数:5,代码来源:Nb2dJson.cs


示例6: SetBodyTypeFromInt

 // REVISADO =====================================================================
 public void SetBodyTypeFromInt(CCPhysicsBody body, int type)
 {
     switch (type)
     {
         case 0:
             body.BodyType = cpBodyType.STATIC;
             //body = CCPhysicsBody.NewStatic(); // CCPhysicsBodyType.b2_staticBody;
             break;
         case 1:
             //body = CCPhysicsBody.NewKinematic(); // CCPhysicsBodyType.b2_kinematicBody;
             body.BodyType = cpBodyType.KINEMATIC;
             break;
         //default:
         //	body = CCPhysicsBody.New(1,1); // = CCPhysicsBodyType.b2_dynamicBody;
         //	break;
     }
 }
开发者ID:netonjm,项目名称:RubeLoader,代码行数:18,代码来源:Nb2dJson.cs


示例7: GetBodyName

 public string GetBodyName(CCPhysicsBody body)
 {
     if (m_bodyToNameMap.ContainsKey(body))
         return m_bodyToNameMap[body];
     return null;
 }
开发者ID:netonjm,项目名称:RubeLoader,代码行数:6,代码来源:Nb2dJson.cs


示例8: 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);
//.........这里部分代码省略.........
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:101,代码来源:PhysicsTest.cs


示例9: CCPhysicsShape

		public CCPhysicsShape()
		{
			_body = null;
			_info = null;
			_type = PhysicsType.UNKNOWN;
			_area = 0;
			_mass = CCPhysicsBody.MASS_DEFAULT;
			_moment = CCPhysicsBody.MOMENT_DEFAULT;
			_tag = 0;
			_categoryBitmask = int.MaxValue;
			_collisionBitmask = int.MaxValue;
			_contactTestBitmask = 0;
			_group = 0;

			_info = new CCPhysicsShapeInfo(this);

			_scaleX = 1.0f;
			_scaleY = 1.0f;
			_newScaleX = 1.0f;
			_newScaleY = 1.0f;
			_dirty = false;

		}
开发者ID:kkarol93,项目名称:CocosSharp,代码行数:23,代码来源:CCPhysicsShape.cs


示例10: Init

		protected bool Init(CCPhysicsBody a, CCPhysicsBody b, float rate)
		{
			if (!base.Init(a, b))
				return false;

			cpConstraint joint = new cpSimpleMotor(GetBodyInfo(a).Body,
												   GetBodyInfo(b).Body,
												  rate);

			if (joint == null)
				return false;

			_info.Add(joint);


			return true;
		}
开发者ID:kkarol93,项目名称:CocosSharp,代码行数:17,代码来源:CCPhysicsJoint.cs


示例11: lookupBodyIndex

 protected int lookupBodyIndex(CCPhysicsBody body)
 {
     int? val = m_bodyToIndexMap[body];
     if (null != val)
         return val.Value;
     else
         return -1;
 }
开发者ID:netonjm,项目名称:RubeLoader,代码行数:8,代码来源:Nb2dJson.cs


示例12: readCustomPropertiesFromJson

        protected void readCustomPropertiesFromJson(CCPhysicsBody item, JObject value)
        {
            if (null == item)
                return;

            if (value["customProperties"] != null)
                return;

            int i = 0;
            JArray propValues = (JArray)value["customProperties"];
            if (null != propValues)
            {
                int numPropValues = propValues.Count;
                for (i = 0; i < numPropValues; i++)
                {
                    JObject propValue = (JObject)propValues[i];
                    string propertyName = propValue["name"].ToString();
                    if (propValue["int"] != null)
                        SetCustomInt(item, propertyName, (int)propValue["int"]);
                    if (propValue["float"] != null)
                        SetCustomFloat(item, propertyName, (float)propValue["float"]);
                    if (propValue["string"] != null)
                        SetCustomString(item, propertyName, propValue["string"].ToString());
                    if (propValue["vec2"] != null)
                        SetCustomVector(item, propertyName, this.jsonToVec("vec2", propValue));
                    if (propValue["bool"] != null)
                        SetCustomBool(item, propertyName, (bool)propValue["bool"]);
                }
            }
        }
开发者ID:netonjm,项目名称:RubeLoader,代码行数:30,代码来源:Nb2dJson.cs


示例13: UpdateBodies

		public virtual void UpdateBodies()
		{
			if (_info.isLocked())
			{
				return;
			}

			// Fixed: netonjm >  issue #4944, contact callback will be invoked when add/remove body, _delayAddBodies maybe changed, so we need make a copy.

			CCPhysicsBody[] addCopy = new CCPhysicsBody[_delayAddBodies.Count];
			_delayAddBodies.CopyTo(addCopy);
			_delayAddBodies.Clear();

			foreach (var body in addCopy)
			{
				DoAddBody(body);
			}

			CCPhysicsBody[] removeCopy = new CCPhysicsBody[_delayRemoveBodies.Count];
			_delayRemoveBodies.CopyTo(removeCopy);

			_delayRemoveBodies.Clear();

			foreach (var body in removeCopy)
			{
				DoRemoveBody(body);
			}
		}
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:28,代码来源:CCPhysicsWorld.cs


示例14: SetBodyName

 //public JObject writeToValue( b2World world) {
 //if (null == world)
 //    return new JObject();
 //return b2j(world);
 //}
 //public String worldToString(b2World world, int indentFactor) {
 //    if (null == world)
 //        return "";
 //    return b2j(world).toString(indentFactor);
 //}
 public void SetBodyName(CCPhysicsBody body, String name)
 {
     m_bodyToNameMap.Add(body, name);
 }
开发者ID:netonjm,项目名称:RubeLoader,代码行数:14,代码来源:Nb2dJson.cs


示例15: 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;

		}
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:32,代码来源:CCPhysicsWorld.cs


示例16: SetCustomFloat

 public void SetCustomFloat(CCPhysicsBody item, String propertyName, float val)
 {
     m_bodiesWithCustomProperties.Add(item);
     GetCustomPropertiesForItem(item, true).m_customPropertyMap_float.Add(propertyName, (float)val);
 }
开发者ID:netonjm,项目名称:RubeLoader,代码行数:5,代码来源:Nb2dJson.cs


示例17: 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;
		}
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:18,代码来源:CCPhysicsWorld.cs


示例18: SetCustomVector

 public void SetCustomVector(CCPhysicsBody item, String propertyName, cpVect val)
 {
     m_bodiesWithCustomProperties.Add(item);
     GetCustomPropertiesForItem(item, true).m_customPropertyMap_cpVect.Add(propertyName, val);
 }
开发者ID:netonjm,项目名称:RubeLoader,代码行数:5,代码来源:Nb2dJson.cs


示例19: DoAddBody

		public virtual void DoAddBody(CCPhysicsBody body)
		{
			if (body.IsEnabled())
			{
				//is gravity enable
				if (!body.IsGravityEnabled())
				{
					body.ApplyForce(-_gravity * body.GetMass());
				}

				// add body to space
				if (body.IsDynamic())
				{
					_info.addBody(body._info);
				}

				// add shapes to space
				foreach (CCPhysicsShape shape in body.GetShapes())
				{
					AddShape(shape);
				}
			}
		}
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:23,代码来源:CCPhysicsWorld.cs


示例20: 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;
		}
开发者ID:h7ing,项目名称:CocosSharp,代码行数:7,代码来源:CCPhysicsBody.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CocosSharp.CCScene类代码示例发布时间:2022-05-24
下一篇:
C# CocosSharp.CCMenu类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap