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

C# CCVector2类代码示例

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

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



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

示例1: GetFontAtlasSpriteFont

        public static CCFontAtlas GetFontAtlasSpriteFont (string fontFileName, float fontSize, CCVector2 imageOffset = default(CCVector2))
        {
            string atlasName = GenerateFontName(fontFileName, (int)fontSize, GlyphCollection.Custom,false);
            var atlasAlreadyExists = atlasMap.ContainsKey(atlasName);

            if (!atlasAlreadyExists)
            {
                var font = new CCFontSpriteFont(fontFileName, fontSize, imageOffset);
                if (font != null)
                {
                    var tempAtlas = font.CreateFontAtlas();
                    if (tempAtlas != null)
                    {
                        atlasMap[atlasName] = tempAtlas;
                        return atlasMap[atlasName];
                    }
                }
            }
            else
            {
                return atlasMap[atlasName];
            }


            return null;
        }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:26,代码来源:CCFontAtlasCache.cs


示例2: GraphicsPathTest

        public GraphicsPathTest()
        {
            _thickPen = new Pen(Microsoft.Xna.Framework.Color.Green, 15);

            List<CCVector2> path1 = new List<CCVector2>() {
                new CCVector2(50, 50), new CCVector2(100, 50), new CCVector2(100, 100), new CCVector2(50, 100),
            };

            _gpathf = new GraphicsPath(_thickPen, path1, PathType.Closed);

            path1.Reverse();
            for (int i = 0; i < path1.Count; i++)
                path1[i] = new CCVector2(path1[i].X + 100, path1[i].Y);

            _gpathr = new GraphicsPath(_thickPen, path1, PathType.Closed);

            for (int i = 0; i < path1.Count; i++)
                path1[i] = new CCVector2(path1[i].X, path1[i].Y + 100);

            _gpath2r = new GraphicsPath(_thickPen, path1);

            path1.Reverse();
            for (int i = 0; i < path1.Count; i++)
                path1[i] = new CCVector2(path1[i].X - 100, path1[i].Y);

            _gpath2f = new GraphicsPath(_thickPen, path1);
        }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:27,代码来源:GraphicsPathTest.cs


示例3: Draw

        public override void Draw(DrawBatch drawBatch)
        {
            float space = 30;
            float macroSpace = 50;
            float length = 200;

            CCVector2 o1 = new CCVector2(macroSpace, macroSpace);
            CCVector2 o2 = new CCVector2(macroSpace * 2 + length, macroSpace);
            CCVector2 o3 = new CCVector2(macroSpace * 2 + length, macroSpace * 2 + length);
            CCVector2 o4 = new CCVector2(macroSpace, macroSpace * 2 + length);

            drawBatch.DrawPath(new GraphicsPath(_flatPen, new List<CCVector2> { o1 + new CCVector2(0, space * 0), o1 + new CCVector2(length, space * 0) }));
            drawBatch.DrawPath(new GraphicsPath(_squarePen, new List<CCVector2> { o1 + new CCVector2(0, space * 1), o1 + new CCVector2(length, space * 1) }));
            drawBatch.DrawPath(new GraphicsPath(_trianglePen, new List<CCVector2> { o1 + new CCVector2(0, space * 2), o1 + new CCVector2(length, space * 2) }));
            drawBatch.DrawPath(new GraphicsPath(_invTrianglePen, new List<CCVector2> { o1 + new CCVector2(0, space * 3), o1 + new CCVector2(length, space * 3) }));
            drawBatch.DrawPath(new GraphicsPath(_arrowPen, new List<CCVector2> { o1 + new CCVector2(0, space * 4), o1 + new CCVector2(length, space * 4) }));

            drawBatch.DrawPath(new GraphicsPath(_flatPen, new List<CCVector2> { o2 + new CCVector2(space * 0, 0), o2 + new CCVector2(space * 0, length) }));
            drawBatch.DrawPath(new GraphicsPath(_squarePen, new List<CCVector2> { o2 + new CCVector2(space * 1, 0), o2 + new CCVector2(space * 1, length) }));
            drawBatch.DrawPath(new GraphicsPath(_trianglePen, new List<CCVector2> { o2 + new CCVector2(space * 2, 0), o2 + new CCVector2(space * 2, length) }));
            drawBatch.DrawPath(new GraphicsPath(_invTrianglePen, new List<CCVector2> { o2 + new CCVector2(space * 3, 0), o2 + new CCVector2(space * 3, length) }));
            drawBatch.DrawPath(new GraphicsPath(_arrowPen, new List<CCVector2> { o2 + new CCVector2(space * 4, 0), o2 + new CCVector2(space * 4, length) }));

            drawBatch.DrawPath(new GraphicsPath(_flatPen, new List<CCVector2> { o3 + new CCVector2(length, space * 0), o3 + new CCVector2(0, space * 0) }));
            drawBatch.DrawPath(new GraphicsPath(_squarePen, new List<CCVector2> { o3 + new CCVector2(length, space * 1), o3 + new CCVector2(0, space * 1) }));
            drawBatch.DrawPath(new GraphicsPath(_trianglePen, new List<CCVector2> { o3 + new CCVector2(length, space * 2), o3 + new CCVector2(0, space * 2) }));
            drawBatch.DrawPath(new GraphicsPath(_invTrianglePen, new List<CCVector2> { o3 + new CCVector2(length, space * 3), o3 + new CCVector2(0, space * 3) }));
            drawBatch.DrawPath(new GraphicsPath(_arrowPen, new List<CCVector2> { o3 + new CCVector2(length, space * 4), o3 + new CCVector2(0, space * 4) }));

            drawBatch.DrawPath(new GraphicsPath(_flatPen, new List<CCVector2> { o4 + new CCVector2(space * 0, length), o4 + new CCVector2(space * 0, 0) }));
            drawBatch.DrawPath(new GraphicsPath(_squarePen, new List<CCVector2> { o4 + new CCVector2(space * 1, length), o4 + new CCVector2(space * 1, 0) }));
            drawBatch.DrawPath(new GraphicsPath(_trianglePen, new List<CCVector2> { o4 + new CCVector2(space * 2, length), o4 + new CCVector2(space * 2, 0) }));
            drawBatch.DrawPath(new GraphicsPath(_invTrianglePen, new List<CCVector2> { o4 + new CCVector2(space * 3, length), o4 + new CCVector2(space * 3, 0) }));
            drawBatch.DrawPath(new GraphicsPath(_arrowPen, new List<CCVector2> { o4 + new CCVector2(space * 4, length), o4 + new CCVector2(space * 4, 0) }));
        }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:35,代码来源:LineCaps.cs


示例4: LineCapInfo

 protected LineCapInfo (float width, CCVector2[] xyBuffer, CCVector2[] uvBuffer, short[] indexBuffer, short[] outlineBuffer)
 {
     _width = width;
     _xyBuffer = xyBuffer;
     _uvBuffer = uvBuffer;
     _indexBuffer = indexBuffer;
     _outlineBuffer = outlineBuffer;
 }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:8,代码来源:LineCapInfo.cs


示例5: Calculate

        public void Calculate (CCVector2 p, CCVector2 edgeAB, PenWorkspace ws, PenAlignment alignment, bool start)
        {
            edgeAB.Normalize();

            // [  eAB.X  -eAB.Y ]
            // [  eAB.Y   eAB.X ]

            float tC = edgeAB.X * _width;
            float tS = edgeAB.Y * _width;

            float tX = p.X;
            float tY = p.Y;

            switch (alignment) {
                case PenAlignment.Center:
                    break;

                case PenAlignment.Inset:
                    if (start) {
                        tX = p.X + (-.5f * tS);
                        tY = p.Y - (-.5f * tC);
                    }
                    else {
                        tX = p.X - (-.5f * tS);
                        tY = p.Y + (-.5f * tC);
                    }
                    break;

                case PenAlignment.Outset:
                    if (start) {
                        tX = p.X + (.5f * tS);
                        tY = p.Y - (.5f * tC);
                    }
                    else {
                        tX = p.X - (.5f * tS);
                        tY = p.Y + (.5f * tC);
                    }
                    break;
            }

            for (int i = 0; i < _xyBuffer.Length; i++)
                ws.XYBuffer[i] = new CCVector2(_xyBuffer[i].X * tC - _xyBuffer[i].Y * tS + tX, _xyBuffer[i].X * tS + _xyBuffer[i].Y * tC + tY);

            for (int i = 0; i < _uvBuffer.Length; i++)
                ws.UVBuffer[i] = _uvBuffer[i];

            for (int i = 0; i < _indexBuffer.Length; i++)
                ws.IndexBuffer[i] = _indexBuffer[i];

            for (int i = 0; i < _outlineBuffer.Length; i++)
                ws.OutlineIndexBuffer[i] = _outlineBuffer[i];

            ws.XYBuffer.Index = _xyBuffer.Length;
            ws.UVBuffer.Index = _uvBuffer.Length;
            ws.IndexBuffer.Index = _indexBuffer.Length;
            ws.OutlineIndexBuffer.Index = _outlineBuffer.Length;
        }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:57,代码来源:LineCapInfo.cs


示例6: CollidesWith

        public virtual bool CollidesWith(CCMaskedSprite target, out CCPoint pt)
        {
            pt = CCPoint.Zero;
            CCAffineTransform affine1 = AffineWorldTransform;
            CCAffineTransform affine2 = target.AffineWorldTransform;
            CCRect myBBInWorld = BoundingBoxTransformedToWorld;
            CCRect targetBBInWorld = target.BoundingBoxTransformedToWorld;

            if (!myBBInWorld.IntersectsRect(targetBBInWorld))
            {
                return (false);
            }
            // Based upon http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series2D/Putting_CD_into_practice.php
            var affine1to2 = affine1 * CCAffineTransform.Invert (affine2);

            int width2 = (int)target.ContentSize.Width;
            int height2 = (int)target.ContentSize.Height;
            int width1 = (int)ContentSize.Width;
            int height1 = (int)ContentSize.Height;
            byte[] maskA = CollisionMask;
            byte[] maskB = target.CollisionMask;
            if (maskA == null || maskB == null)
            {
                return (false);
            }
            for (int x1 = 0; x1 < width1; x1++)
            {
                for (int y1 = 0; y1 < height1; y1++)
                {
                    var pos1 = new CCVector2(x1, y1);
                    var pos2 = CCVector2.Transform (pos1, affine1to2);

                    int x2 = (int)pos2.X;
                    int y2 = (int)pos2.Y;
                    if ((x2 >= 0) && (x2 < width2))
                    {
                        if ((y2 >= 0) && (y2 < height2))
                        {
                            int iA = x1 + (height1-y1) * width1;
                            int iB = x2 + (height2-y2) * width2;
                            if (iA >= maskA.Length || iB >= maskB.Length)
                                continue;
                            if (maskA[iA] > 0){
                                if (maskB[iB] > 0){
                                    CCVector2 screenPos = CCVector2.Transform(pos1, affine1);
                                    pt = new CCPoint(screenPos);
                                    return (true);
                                }
                            }
                        }
                    }
                }
            }

            return false;
        }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:56,代码来源:CCMaskedSprite.cs


示例7: JoinSample

        public JoinSample (CCVector2 pointA, CCVector2 pointB, CCVector2 pointC, float lengthA, float lengthB, float lengthC)
        {
            PointA = pointA;
            PointB = pointB;
            PointC = pointC;

            LengthA = lengthA;
            LengthB = lengthB;
            LengthC = lengthC;
        }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:10,代码来源:PenWorkspace.cs


示例8: Advance

        public void Advance (CCVector2 nextPoint, float nextLength)
        {
            PointA = PointB;
            PointB = PointC;
            PointC = nextPoint;

            LengthA = LengthB;
            LengthB = LengthC;
            LengthC = nextLength;
        }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:10,代码来源:PenWorkspace.cs


示例9: CCFontSpriteFont

        public CCFontSpriteFont (string fntFilePath, float fontSize, CCVector2? imageOffset = null)
        { 
            fontName = fntFilePath;
            this.fontSize = fontSize;

            this.imageOffset = CCVector2.Zero;

            if (imageOffset.HasValue)
                this.imageOffset = imageOffset.Value;

            fontScale = 1.0f;
        }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:12,代码来源:CCFontSpriteFont.cs


示例10: CCFontFNT

        public CCFontFNT(string fntFilePath, CCVector2? imageOffset = null)
        { 
            
            Configuration = CCBMFontConfiguration.FontConfigurationWithFile(fntFilePath);
            this.imageOffset = CCVector2.Zero;

            if (imageOffset.HasValue)
                this.imageOffset = imageOffset.Value;

            if (Configuration != null)
                IsFontConfigValid = true;
        }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:12,代码来源:CCFontFNT.cs


示例11: BuildLillyPad

        private static PathBuilder BuildLillyPad(CCVector2 center, int radius, float rotation)
        {
            float segment = (float)(Math.PI * 2 / 32);

            PathBuilder builder = new PathBuilder();

            builder.AddPoint(center);
            builder.AddLine(radius, segment * 25 + rotation);
            builder.AddArcByAngle(center, segment * 30, radius / 2);

            return builder;
        }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:12,代码来源:IntroLayer.cs


示例12: Initialize

            public void Initialize(CCRect bounds, float mag)
            {
                ColorPen = new Pen(new Microsoft.Xna.Framework.Color(rand.Next(255), rand.Next(255), rand.Next(255)));

                for (int i = 0; i < Points.Length; i++)
                {
                    Points[i] = new CCVector2(bounds.MinX + (float)rand.NextDouble() * bounds.Size.Width, bounds.MaxY + (float)rand.NextDouble() * bounds.Size.Height);
                    Velocities[i] = new CCVector2((float)(rand.NextDouble() - .5) * mag, (float)(rand.NextDouble() - .5) * mag);

                    for (int j = 0; j < History.Count; j++)
                        History[j][i] = Points[i];
                }
            }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:13,代码来源:Mystify.cs


示例13: CreateFlowerGP

        private GraphicsPath CreateFlowerGP(Pen pen, CCVector2 center, int petalCount, float petalLength, float petalWidth, float rotation)
        {
            List<CCVector2> points = StarPoints(center, petalCount / 2, petalLength, petalLength, rotation, false);

            PathBuilder builder = new PathBuilder();
            builder.AddPoint(center);

            foreach (CCVector2 point in points)
            {
                builder.AddArcByPoint(point, petalWidth / 2);
                builder.AddArcByPoint(center, petalWidth / 2);
            }

            return builder.Stroke(pen, PathType.Closed);
        }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:15,代码来源:WaterLilly.cs


示例14: GetFontAtlasFNT

        public static CCFontAtlas GetFontAtlasFNT(CCFontFNT font, CCVector2 imageOffset = default(CCVector2))
        {
            if (font != null)
            {
                var atlasName = font.Configuration.AtlasName;
                var tempAtlas = font.CreateFontAtlas();
                if (tempAtlas != null)
                {
                    atlasMap[atlasName] = tempAtlas;
                    return atlasMap[atlasName];
                }
            }


            return null;
        }
开发者ID:haithemaraissia,项目名称:CocosSharp,代码行数:16,代码来源:CCFontAtlasCache.cs


示例15: StarPoints

        protected static List<CCVector2> StarPoints(CCVector2 center, int pointCount, float outerRadius, float innerRadius, float rotation, bool close)
        {
            List<CCVector2> points = new List<CCVector2>();

            int limit = (close) ? pointCount * 2 + 1 : pointCount * 2;

            float rot = (float)((Math.PI * 2) / (pointCount * 2));
            for (int i = 0; i < limit; i++)
            {
                float si = (float)Math.Sin(-i * rot + Math.PI + rotation);
                float ci = (float)Math.Cos(-i * rot + Math.PI + rotation);

                if (i % 2 == 0)
                    points.Add(center + new CCVector2(si, ci) * outerRadius);
                else
                    points.Add(center + new CCVector2(si, ci) * innerRadius);
            }

            return points;
        }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:20,代码来源:TestLayer.cs


示例16: CCFontFNT

        /// <summary>
        /// Constructor to create a Bitmap Font configuration object from a .FNT configuration file
        /// string to be parsed and a Stream object of the Atlas Texture to be used.
        /// </summary>
        /// <param name="configInfo">String representation read from a .FNT configuration</param>
        /// <param name="atlasTexture">CCTexture2D Atlas to be used.</param>
        /// <param name="imageOffset">Image Offset</param>
        public CCFontFNT(string configInfo, CCTexture2D atlasTexture, CCVector2? imageOffset = null)
        {

            try
            {
                Configuration = new CCBMFontConfiguration(configInfo, string.Empty);
            }
            catch (Exception exc)
            {
                throw new ContentLoadException("Bitmap Font Configuration is invalid: " + exc.Message);
            }

            this.imageOffset = CCVector2.Zero;

            if (imageOffset.HasValue)
                this.imageOffset = imageOffset.Value;

            AtlasTexture = atlasTexture;

            if (Configuration != null)
                IsFontConfigValid = true;
        }
开发者ID:haithemaraissia,项目名称:CocosSharp,代码行数:29,代码来源:CCFontFNT.cs


示例17: DrawFixture

        private void DrawFixture(Fixture fixture)
        {
            Color color = new Color(0.95f, 0.95f, 0.6f);
            Transform xf;
            fixture.Body.GetTransform(out xf);

            switch (fixture.Shape.ShapeType)
            {
                case ShapeType.Circle:
                    {
                        CircleShape circle = (CircleShape)fixture.Shape;

                        Vector2 center = MathUtils.Multiply(ref xf, circle.Position);
                        float radius = circle.Radius;

                        DebugDraw.DrawSolidCircle(center, radius, Vector2.Zero, color);
                    }
                    break;

                case ShapeType.Polygon:
                    {
                        PolygonShape poly = (PolygonShape)fixture.Shape;
                        int vertexCount = poly.Vertices.Count;
                        Debug.Assert(vertexCount <= Settings.MaxPolygonVertices);
                        CCVector2[] vertices = new CCVector2[Settings.MaxPolygonVertices];

                        for (int i = 0; i < vertexCount; ++i)
                        {
                            vertices[i] = (CCVector2)MathUtils.Multiply(ref xf, poly.Vertices[i]);
                        }

					DebugDraw.DrawSolidPolygon(vertices, vertexCount, color);
                    }
                    break;
            }
        }
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:36,代码来源:PolyShapesTest.cs


示例18: Update

        public override void Update(GameSettings settings, GameTime gameTime)
        {
            Manifold manifold = new Manifold();
            Collision.Collision.CollidePolygons(ref manifold, _polygonA, ref _transformA, _polygonB, ref _transformB);

            Vector2 normal;
            FixedArray2<Vector2> points;
            Collision.Collision.GetWorldManifold(ref manifold, ref _transformA, _polygonA.Radius,
                                                 ref _transformB, _polygonB.Radius, out normal, out points);

            DebugView.DrawString(50, TextLine, "Point count = {0:n0}", manifold.PointCount);
            TextLine += 15;
            DebugView.BeginCustomDraw();
            {
                Color color = new Color(0.9f, 0.9f, 0.9f);
                CCVector2[] v = new CCVector2[Settings.MaxPolygonVertices];
                for (int i = 0; i < _polygonA.Vertices.Count; ++i)
                {
                    v[i] = (CCVector2)MathUtils.Multiply(ref _transformA, _polygonA.Vertices[i]);
                }

				DebugView.DrawPolygon(v, _polygonA.Vertices.Count, color);

                for (int i = 0; i < _polygonB.Vertices.Count; ++i)
                {
                    v[i] = (CCVector2)MathUtils.Multiply(ref _transformB, _polygonB.Vertices[i]);
                }
				DebugView.DrawPolygon(v, _polygonB.Vertices.Count, color);
            }

            for (int i = 0; i < manifold.PointCount; ++i)
            {
                DebugView.DrawPoint(points[i], 0.1f, new Color(0.9f, 0.3f, 0.3f));
            }
            DebugView.EndCustomDraw();
        }
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:36,代码来源:PolyCollisionTest.cs


示例19: TriangleIsCCW

 private bool TriangleIsCCW (CCVector2 a, CCVector2 b, CCVector2 c)
 {
     return Cross2D(b - a, c - b) < 0;
 }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:4,代码来源:Triangulator.cs


示例20: DrawPrimitiveEllipse

 /// <summary>
 /// Adds a primitive ellipse path to the batch of figures to be rendered.
 /// </summary>
 /// <param name="pen">The pen supplying the color to render the path with.</param>
 /// <param name="center">The center of the ellipse.</param>
 /// <param name="xRadius">The radius of the ellipse along the x-axis.</param>
 /// <param name="yRadius">The radius of the ellipse along the y-acis.</param>
 /// <param name="angle">The angle to rotate the ellipse by in radians.  Positive values rotate clockwise.</param>
 /// <exception cref="InvalidOperationException"><c>DrawPrimitiveEllipse</c> was called, but <see cref="Begin()"/> has not yet been called.</exception>
 /// <remarks>The number of subdivisions in the ellipse is computed as max(xRadius, yRadius) / 1.5.</remarks>
 public void DrawPrimitiveEllipse (Pen pen, CCVector2 center, float xRadius, float yRadius, float angle)
 {
     DrawPrimitiveEllipse(pen, center, xRadius, yRadius, angle, DefaultSubdivisions(xRadius, yRadius));
 }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:14,代码来源:DrawBatch.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# CCVerticalTextAlignment类代码示例发布时间:2022-05-24
下一篇:
C# CCTexture2D类代码示例发布时间: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