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


C# b2Vec2.ToVector2方法代码示例

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


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

示例1: DrawSegment

 public override void DrawSegment(b2Vec2 p1, b2Vec2 p2, b2Color color)
 {
     if (!_primitiveBatch.IsReady())
     {
         throw new InvalidOperationException("BeginCustomDraw must be called before drawing anything.");
     }
     _primitiveBatch.AddVertex(p1.ToVector2(), color.ToColor(), PrimitiveType.LineList);
     _primitiveBatch.AddVertex(p2.ToVector2(), color.ToColor(), PrimitiveType.LineList);
 }
开发者ID:womandroid,项目名称:cocos2d-xna,代码行数:9,代码来源:CCDraw.cs

示例2: DrawCircle

        public override void DrawCircle(b2Vec2 center, float radius, b2Color color)
        {
            if (!_primitiveBatch.IsReady())
            {
                throw new InvalidOperationException("BeginCustomDraw must be called before drawing anything.");
            }
            const double increment = Math.PI * 2.0 / CircleSegments;
            double theta = 0.0;

            var col = color.ToColor();
            Vector2 centr = center.ToVector2();

            for (int i = 0, count = CircleSegments; i < count; i++)
            {
                Vector2 v1 = centr + radius * new Vector2((float) Math.Cos(theta), (float) Math.Sin(theta));
                Vector2 v2 = centr +
                             radius *
                             new Vector2((float) Math.Cos(theta + increment), (float) Math.Sin(theta + increment));

                _primitiveBatch.AddVertex(ref v1, col, PrimitiveType.LineList);
                _primitiveBatch.AddVertex(ref v2, col, PrimitiveType.LineList);

                theta += increment;
            }
        }
开发者ID:womandroid,项目名称:cocos2d-xna,代码行数:25,代码来源:CCDraw.cs

示例3: DrawSolidCircle

        public override void DrawSolidCircle(b2Vec2 center, float radius, b2Vec2 axis, b2Color color)
        {
            if (!_primitiveBatch.IsReady())
            {
                throw new InvalidOperationException("BeginCustomDraw must be called before drawing anything.");
            }
            const double increment = Math.PI * 2.0 / CircleSegments;
            double theta = 0.0;

            var colorFill = color.ToColor() * 0.5f;
            var centr = center.ToVector2();

            Vector2 v0 = center.ToVector2() + radius * new Vector2((float) Math.Cos(theta), (float) Math.Sin(theta));
            theta += increment;

            for (int i = 1; i < CircleSegments - 1; i++)
            {
                var v1 = centr + radius * new Vector2((float) Math.Cos(theta), (float) Math.Sin(theta));
                var v2 = centr +
                         radius * new Vector2((float) Math.Cos(theta + increment), (float) Math.Sin(theta + increment));

                _primitiveBatch.AddVertex(ref v0, colorFill, PrimitiveType.TriangleList);
                _primitiveBatch.AddVertex(ref v1, colorFill, PrimitiveType.TriangleList);
                _primitiveBatch.AddVertex(ref v2, colorFill, PrimitiveType.TriangleList);

                theta += increment;
            }
            DrawCircle(center, radius, color);

            DrawSegment(center, center + axis * radius, color);
        }
开发者ID:womandroid,项目名称:cocos2d-xna,代码行数:31,代码来源:CCDraw.cs


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