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


C# CCVector2类代码示例

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


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


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