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


C# Path.add方法代码示例

本文整理汇总了C#中FarseerPhysics.Common.Path.add方法的典型用法代码示例。如果您正苦于以下问题:C# Path.add方法的具体用法?C# Path.add怎么用?C# Path.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FarseerPhysics.Common.Path的用法示例。


在下文中一共展示了Path.add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateChain

		/// <summary>
		/// Creates the chain.
		/// </summary>
		/// <returns>The chain.</returns>
		/// <param name="world">World.</param>
		/// <param name="start">Start.</param>
		/// <param name="end">End.</param>
		/// <param name="linkWidth">Link width.</param>
		/// <param name="linkHeight">Link height.</param>
		/// <param name="numberOfLinks">Number of links.</param>
		/// <param name="linkDensity">Link density.</param>
		/// <param name="attachRopeJoint">Creates a rope joint between start and end. This enforces the length of the rope. Said in another way: it makes the rope less bouncy.</param>
		/// <param name="fixStart">If set to <c>true</c> fix start.</param>
		/// <param name="fixEnd">If set to <c>true</c> fix end.</param>
		public static List<Body> CreateChain( World world, Vector2 start, Vector2 end, float linkWidth, float linkHeight, int numberOfLinks, float linkDensity, bool attachRopeJoint, bool fixStart = false, bool fixEnd = false )
		{
			Debug.Assert( numberOfLinks >= 2 );

			// Chain start / end
			var path = new Path();
			path.add( start );
			path.add( end );

			// A single chainlink
			var shape = new PolygonShape( PolygonTools.createRectangle( linkWidth, linkHeight ), linkDensity );

			// Use PathManager to create all the chainlinks based on the chainlink created before.
			var chainLinks = PathManager.evenlyDistributeShapesAlongPath( world, path, shape, BodyType.Dynamic, numberOfLinks );

			if( fixStart )
			{
				// Fix the first chainlink to the world
				var axle = BodyFactory.CreateCircle( world, 0.1f, 1, chainLinks[0].position );
				JointFactory.CreateRevoluteJoint( world, chainLinks[0], axle, new Vector2( 0, -( linkHeight / 2 ) ), Vector2.Zero );
			}

			if( fixEnd )
			{
				// Fix the last chainlink to the world
				var lastIndex = chainLinks.Count - 1;
				var axle = BodyFactory.CreateCircle( world, 0.1f, 1, chainLinks[lastIndex].position );
				JointFactory.CreateRevoluteJoint( world, chainLinks[lastIndex], axle, new Vector2( 0, -( linkHeight / 2 ) ), Vector2.Zero );
			}

			// Attach all the chainlinks together with a revolute joint
			PathManager.attachBodiesWithRevoluteJoint( world, chainLinks, new Vector2( 0, -linkHeight ), new Vector2( 0, linkHeight ), false, false );

			if( attachRopeJoint )
				JointFactory.CreateRopeJoint( world, chainLinks[0], chainLinks[chainLinks.Count - 1], Vector2.Zero, Vector2.Zero );

			return chainLinks;
		}
开发者ID:prime31,项目名称:Nez,代码行数:52,代码来源:LinkFactory.cs


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