Exemplo n.º 1
0
        public override void Visit()
        {
            base.Visit();

            float   dx     = Position.X - AnchorPoint.X * ContentSize.Width;
            float   dy     = Position.Y - AnchorPoint.Y * ContentSize.Height;
            CCPoint offset = new CCPoint(dx, dy);

            CCPoint[] pv = new CCPoint[_polyVertices.Length];
            for (int i = 0; i < _polyVertices.Length; i++)
            {
                pv[i] = _polyVertices[i] + offset;
            }
            CCDrawingPrimitives.Begin();
            CCDrawingPrimitives.DrawSolidPoly(pv, 4 * _cornerSegments + 1, Color);
            CCDrawingPrimitives.DrawCubicBezier(_vertices[0] + offset, _vertices[1] + offset, _vertices[2] + offset, _vertices[3] + offset, _cornerSegments, Color);
            CCDrawingPrimitives.DrawCubicBezier(_vertices[4] + offset, _vertices[5] + offset, _vertices[6] + offset, _vertices[7] + offset, _cornerSegments, Color);
            CCDrawingPrimitives.DrawCubicBezier(_vertices[8] + offset, _vertices[9] + offset, _vertices[10] + offset, _vertices[11] + offset, _cornerSegments, Color);
            CCDrawingPrimitives.DrawCubicBezier(_vertices[12] + offset, _vertices[13] + offset, _vertices[14] + offset, _vertices[15] + offset, _cornerSegments, Color);

            CCDrawingPrimitives.End();

            CCDrawingPrimitives.Begin();
            CCDrawingPrimitives.DrawLine(_vertices[3] + offset, _vertices[4] + offset, Color);
            CCDrawingPrimitives.DrawLine(_vertices[7] + offset, _vertices[8] + offset, Color);
            CCDrawingPrimitives.DrawLine(_vertices[11] + offset, _vertices[12] + offset, Color);
            CCDrawingPrimitives.DrawLine(_vertices[15] + offset, _vertices[0] + offset, Color);

            CCDrawingPrimitives.End();
        }
Exemplo n.º 2
0
 protected override void Draw()
 {
     base.Draw();
     CCDrawingPrimitives.Begin();
     CCDrawingPrimitives.DrawSolidPoly(circleVertices, numberOfSegments, new CCColor4B(Color.R, Color.G, Color.B));
     CCDrawingPrimitives.End();
 }
Exemplo n.º 3
0
        public override void draw()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            CCDrawingPrimitives.ccDrawLine(new CCPoint(0, s.height / 2), new CCPoint(s.width, s.height / 2), new ccColor4F(255, 0, 0, 255));
            CCDrawingPrimitives.ccDrawLine(new CCPoint(s.width / 2, 0), new CCPoint(s.width / 2, s.height), new ccColor4F(255, 0, 0, 255));
        }
Exemplo n.º 4
0
        protected override void Draw()
        {
            var map = (CCTMXTiledMap)GetChildByTag(kTagTileMap);
            CCTMXObjectGroup group = map.ObjectGroupNamed("Object Layer 1");

            foreach (var dict in group.Objects)
            {
                int x      = int.Parse(dict["x"]);
                int y      = int.Parse(dict["y"]);
                int width  = dict.ContainsKey("width") ? int.Parse(dict["width"]) : 0;
                int height = dict.ContainsKey("height") ? int.Parse(dict["height"]) : 0;

                //glLineWidth(3);

                var color = new CCColor4B(255, 255, 0, 255);

                CCDrawingPrimitives.Begin();
                CCDrawingPrimitives.DrawLine(new CCPoint(x, y), new CCPoint(x + width, y), color);
                CCDrawingPrimitives.DrawLine(new CCPoint(x + width, y), new CCPoint(x + width, y + height), color);
                CCDrawingPrimitives.DrawLine(new CCPoint(x + width, y + height), new CCPoint(x, y + height), color);
                CCDrawingPrimitives.DrawLine(new CCPoint(x, y + height), new CCPoint(x, y), color);
                CCDrawingPrimitives.End();

                //glLineWidth(1);
            }
        }
Exemplo n.º 5
0
 public void Draw()
 {
     base.Draw();
     CCDrawingPrimitives.Begin();
     CCDrawingPrimitives.DrawRect(new CCRect(0, 0, this.ContentSize.Width, this.ContentSize.Height), CCColor4B.Blue);
     CCDrawingPrimitives.End();
 }
Exemplo n.º 6
0
 public override void Draw()
 {
     CCDrawingPrimitives.Begin();
     CCDrawingPrimitives.DrawSolidRect(CCPoint.Zero, new CCPoint(-100, -100), Colour.Red);
     CCDrawingPrimitives.End();
     base.Draw();
 }
Exemplo n.º 7
0
        public override void Draw()
        {
            CCDrawingPrimitives.Begin();
            CCDrawingPrimitives.DrawSolidRect(PointVector.Zero, bottomRight, colour);
            CCDrawingPrimitives.End();

            base.Draw();
        }
Exemplo n.º 8
0
        protected override void Draw()
        {
            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            CCDrawingPrimitives.Begin();
            CCDrawingPrimitives.DrawLine(new CCPoint(0, s.Height / 2), new CCPoint(s.Width, s.Height / 2));
            CCDrawingPrimitives.DrawLine(new CCPoint(s.Width / 2, 0), new CCPoint(s.Width / 2, s.Height));
            CCDrawingPrimitives.End();
        }
Exemplo n.º 9
0
        public override void Draw()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCDrawingPrimitives.Begin();
            CCDrawingPrimitives.DrawLine(new CCPoint(0, s.Height / 2), new CCPoint(s.Width, s.Height / 2), new CCColor4B(255, 0, 0, 255));
            CCDrawingPrimitives.DrawLine(new CCPoint(s.Width / 2, 0), new CCPoint(s.Width / 2, s.Height), new CCColor4B(255, 0, 0, 255));
            CCDrawingPrimitives.End();
        }
        protected override void Draw()
        {
            CCSize visibleBoundsSize = VisibleBoundsWorldspace.Size;

            if (IsDebug)
            {
                CCDrawingPrimitives.Begin();
                CCDrawingPrimitives.DrawRect(new CCRect(0, 0, visibleBoundsSize.Width, visibleBoundsSize.Height), CCColor4B.Blue);
                CCDrawingPrimitives.End();
            }
        }
Exemplo n.º 11
0
 public override void Draw()
 {
     CCDrawingPrimitives.Begin();
     CCDrawingPrimitives.DrawLine(new CCPoint(0, _touchPoint.Y), new CCPoint(ContentSize.Width, _touchPoint.Y),
                                  new CCColor4B(_touchColor.R, _touchColor.G, _touchColor.B, 255));
     CCDrawingPrimitives.DrawLine(new CCPoint(_touchPoint.X, 0), new CCPoint(_touchPoint.X, ContentSize.Height),
                                  new CCColor4B(_touchColor.R, _touchColor.G, _touchColor.B, 255));
     CCDrawingPrimitives.DrawPoint(_touchPoint, 30,
                                   new CCColor4B(_touchColor.R, _touchColor.G, _touchColor.B, 255));
     CCDrawingPrimitives.End();
 }
Exemplo n.º 12
0
        protected override void Draw()
        {
            base.Draw();

            var color = new CCColor4B(Color.R, Color.G, Color.B);

            CCDrawingPrimitives.Begin();
            CCDrawingPrimitives.LineWidth = 2.0f;
            CCDrawingPrimitives.DrawEllipse(Rect, color);
            CCDrawingPrimitives.End();
        }
Exemplo n.º 13
0
 protected override void Draw()
 {
     CCDrawingPrimitives.Begin();
     CCDrawingPrimitives.DrawColor = new CCColor4B(_touchColor.R, _touchColor.G, _touchColor.B, 255);
     CCDrawingPrimitives.LineWidth = 10;
     CCDrawingPrimitives.DrawLine(new CCPoint(0, _touchPoint.Y), new CCPoint(ContentSize.Width, _touchPoint.Y));
     CCDrawingPrimitives.DrawLine(new CCPoint(_touchPoint.X, 0), new CCPoint(_touchPoint.X, ContentSize.Height));
     CCDrawingPrimitives.LineWidth = 1;
     CCDrawingPrimitives.PointSize = 30;
     CCDrawingPrimitives.DrawPoint(_touchPoint);
     CCDrawingPrimitives.End();
 }
Exemplo n.º 14
0
        public override void Draw()
        {
            base.Draw();

            // move to 50,50 since the "by" path will start at 50,50
            CCDrawManager.PushMatrix();
            CCDrawManager.Translate(50, 50, 0);
            CCDrawingPrimitives.DrawCatmullRom(m_pArray, 50);
            CCDrawManager.PopMatrix();

            CCDrawingPrimitives.DrawCatmullRom(m_pArray2, 50);
        }
Exemplo n.º 15
0
        protected override void Draw()
        {
            base.Draw();

            if (!IsDebug)
            {
                return;
            }

            CCDrawingPrimitives.Begin();
            CCDrawingPrimitives.DrawRect(new CCRect(0, 0, this.ContentSize.Width, this.ContentSize.Height), CCColor4B.Blue);
            CCDrawingPrimitives.End();
        }
Exemplo n.º 16
0
        public override void Draw()
        {
            base.Draw();

            // move to 50,50 since the "by" path will start at 50,50
            CCDrawManager.PushMatrix();
            CCDrawManager.Translate(50, 50, 0);
            CCDrawingPrimitives.DrawCardinalSpline(m_pArray, 0, 100);
            CCDrawManager.PopMatrix();

            var s = CCDirector.SharedDirector.WinSize;

            CCDrawManager.PushMatrix();
            CCDrawManager.Translate(s.Width / 2, 50, 0);
            CCDrawingPrimitives.DrawCardinalSpline(m_pArray, 1, 100);
            CCDrawManager.PopMatrix();
        }
Exemplo n.º 17
0
        public override void Draw()
        {
            //
            // IMPORTANT:
            // This is only for debug purposes
            // It is recommend to disable it
            //
            base.Draw();

            //ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );

            //kmGLPushMatrix();

            CCDrawingPrimitives.Begin();
            _world.DrawDebugData();
            CCDrawingPrimitives.End();

            //world.DrawDebugData();

            //kmGLPopMatrix();
        }
Exemplo n.º 18
0
        public override void draw()
        {
            CCTMXTiledMap    map   = (CCTMXTiledMap)getChildByTag(1);
            CCTMXObjectGroup group = map.objectGroupNamed("Object Group 1");

            List <Dictionary <string, string> > objects = group.Objects;
            Dictionary <string, string>         dict;

            for (int i = 0; i < objects.Count; i++)
            {
                dict = objects[i];//dynamic_cast<CCStringToStringDictionary*>(*it);

                if (dict == null)
                {
                    break;
                }
                string key = "x";
                int    x   = int.Parse(dict[key]); //dynamic_cast<NSNumber*>(dict->objectForKey("x"))->getNumber();
                key = "y";
                int y = int.Parse(dict[key]);      //dynamic_cast<NSNumber*>(dict->objectForKey("y"))->getNumber();
                key = "width";
                int width = int.Parse(dict[key]);  //dynamic_cast<NSNumber*>(dict->objectForKey("width"))->getNumber();
                key = "height";
                int height = int.Parse(dict[key]); //dynamic_cast<NSNumber*>(dict->objectForKey("height"))->getNumber();


                //glLineWidth(3);

                ccColor4F color = new ccColor4F(255, 255, 255, 255);

                CCDrawingPrimitives.ccDrawLine(new CCPoint(x, y), new CCPoint(x + width, y), color);
                CCDrawingPrimitives.ccDrawLine(new CCPoint(x + width, y), new CCPoint(x + width, y + height), color);
                CCDrawingPrimitives.ccDrawLine(new CCPoint(x + width, y + height), new CCPoint(x, y + height), color);
                CCDrawingPrimitives.ccDrawLine(new CCPoint(x, y + height), new CCPoint(x, y), color);

                //glLineWidth(1);
            }
        }
Exemplo n.º 19
0
        protected override void Draw()
        {
            base.Draw();

            CCColor4B color = new CCColor4B(1.0f, 1.0f, 1.0f, 1.0f);

            CCDrawingPrimitives.Begin();

            switch (_lineType)
            {
            case lineTypes.LINE_NONE:
                break;

            case lineTypes.LINE_TEMP:

                //CCDrawingPrimitives.Begin();
                CCDrawingPrimitives.DrawLine(_tip, _pivot, color);
                CCDrawingPrimitives.DrawCircle(_pivot, 10, CCMathHelper.ToRadians(360), 10, false, color);
                //CCDrawingPrimitives.End();

                break;

            case lineTypes.LINE_DASHED:

                //CCDrawingPrimitives.Begin();
                CCDrawingPrimitives.DrawCircle(_pivot, 10, (float)Math.PI, 10, false, color);
                //CCDrawingPrimitives.End();

                int segments = (int)(_lineLength / (_dash + _dashSpace));

                float t = 0.0f;
                float x_;
                float y_;

                for (int i = 0; i < segments + 1; i++)
                {
                    x_ = _pivot.X + t * (_tip.X - _pivot.X);
                    y_ = _pivot.Y + t * (_tip.Y - _pivot.Y);

                    //CCDrawingPrimitives.Begin();
                    CCDrawingPrimitives.DrawCircle(new CCPoint(x_, y_), 4, (float)Math.PI, 6, false, color);
                    //CCDrawingPrimitives.End();

                    t += (float)1 / segments;
                }
                break;
            }

            //draw energy bar
            color = new CCColor4B(0.0f, 0.0f, 0.0f, 1.0f);

            CCDrawingPrimitives.DrawLine(
                new CCPoint(_energyLineX, _screenSize.Height * 0.1f),
                new CCPoint(_energyLineX, _screenSize.Height * 0.9f),
                color);

            color = new CCColor4B(1.0f, 0.5f, 0.0f, 1.0f);

            CCDrawingPrimitives.DrawLine(
                new CCPoint(_energyLineX, _screenSize.Height * 0.1f),
                new CCPoint(_energyLineX, _screenSize.Height * 0.1f + _energy * _energyHeight),
                color);

            CCDrawingPrimitives.End();
        }
Exemplo n.º 20
0
        protected override void Draw()
        {
            defaultBlendState = PremultipliedAlpha ? BlendState.AlphaBlend : BlendState.NonPremultiplied;


            float[]     vertices = this.vertices;
            List <Slot> drawOrder = Skeleton.DrawOrder;
            float       x = Skeleton.X, y = Skeleton.Y;

            CCColor3B color3b   = Color;
            float     skeletonR = color3b.R / 255f;
            float     skeletonG = color3b.G / 255f;
            float     skeletonB = color3b.B / 255f;
            float     skeletonA = Opacity / 255f;

            batcher.BlendState = defaultBlendState;

            batcher.Begin();

            for (int i = 0, n = drawOrder.Count; i < n; i++)
            {
                Slot       slot       = drawOrder[i];
                Attachment attachment = slot.Attachment;
                if (attachment is RegionAttachment)
                {
                    RegionAttachment regionAttachment = (RegionAttachment)attachment;
                    BlendState       blend            = slot.Data.AdditiveBlending ? BlendState.Additive : defaultBlendState;
                    //batcher.BlendState = blend;

                    if (CCDrawManager.GraphicsDevice.BlendState != blend)
                    {
                        batcher.End();
                        batcher.BlendState = blend;
                        batcher.Begin();
                    }

                    MeshItem item = batcher.NextItem(4, 6);
                    item.triangles = quadTriangles;
                    VertexPositionColorTexture[] itemVertices = item.vertices;

                    AtlasRegion region = (AtlasRegion)regionAttachment.RendererObject;
                    item.texture = (Texture2D)region.page.rendererObject;

                    Color color;
                    float a = skeletonA * slot.A * regionAttachment.A;
                    if (PremultipliedAlpha)
                    {
                        color = new Color(
                            skeletonR * slot.R * regionAttachment.R * a,
                            skeletonG * slot.G * regionAttachment.G * a,
                            skeletonB * slot.B * regionAttachment.B * a, a);
                    }
                    else
                    {
                        color = new Color(
                            skeletonR * slot.R * regionAttachment.R,
                            skeletonG * slot.G * regionAttachment.G,
                            skeletonB * slot.B * regionAttachment.B, a);
                    }
                    itemVertices[TL].Color = color;
                    itemVertices[BL].Color = color;
                    itemVertices[BR].Color = color;
                    itemVertices[TR].Color = color;

                    regionAttachment.ComputeWorldVertices(x, y, slot.Bone, vertices);
                    itemVertices[TL].Position.X = vertices[RegionAttachment.X1];
                    itemVertices[TL].Position.Y = vertices[RegionAttachment.Y1];
                    itemVertices[TL].Position.Z = 0;
                    itemVertices[BL].Position.X = vertices[RegionAttachment.X2];
                    itemVertices[BL].Position.Y = vertices[RegionAttachment.Y2];
                    itemVertices[BL].Position.Z = 0;
                    itemVertices[BR].Position.X = vertices[RegionAttachment.X3];
                    itemVertices[BR].Position.Y = vertices[RegionAttachment.Y3];
                    itemVertices[BR].Position.Z = 0;
                    itemVertices[TR].Position.X = vertices[RegionAttachment.X4];
                    itemVertices[TR].Position.Y = vertices[RegionAttachment.Y4];
                    itemVertices[TR].Position.Z = 0;

                    float[] uvs = regionAttachment.UVs;
                    itemVertices[TL].TextureCoordinate.X = uvs[RegionAttachment.X1];
                    itemVertices[TL].TextureCoordinate.Y = uvs[RegionAttachment.Y1];
                    itemVertices[BL].TextureCoordinate.X = uvs[RegionAttachment.X2];
                    itemVertices[BL].TextureCoordinate.Y = uvs[RegionAttachment.Y2];
                    itemVertices[BR].TextureCoordinate.X = uvs[RegionAttachment.X3];
                    itemVertices[BR].TextureCoordinate.Y = uvs[RegionAttachment.Y3];
                    itemVertices[TR].TextureCoordinate.X = uvs[RegionAttachment.X4];
                    itemVertices[TR].TextureCoordinate.Y = uvs[RegionAttachment.Y4];
                }
                else if (attachment is MeshAttachment)
                {
                    MeshAttachment mesh        = (MeshAttachment)attachment;
                    int            vertexCount = mesh.Vertices.Length;
                    if (vertices.Length < vertexCount)
                    {
                        vertices = new float[vertexCount];
                    }
                    mesh.ComputeWorldVertices(x, y, slot, vertices);

                    int[]    triangles = mesh.Triangles;
                    MeshItem item      = batcher.NextItem(vertexCount, triangles.Length);
                    item.triangles = triangles;

                    AtlasRegion region = (AtlasRegion)mesh.RendererObject;
                    item.texture = (Texture2D)region.page.rendererObject;

                    Color color;
                    float a = skeletonA * slot.A * mesh.A;
                    if (PremultipliedAlpha)
                    {
                        color = new Color(
                            skeletonR * slot.R * mesh.R * a,
                            skeletonG * slot.G * mesh.G * a,
                            skeletonB * slot.B * mesh.B * a, a);
                    }
                    else
                    {
                        color = new Color(
                            skeletonR * slot.R * mesh.R,
                            skeletonG * slot.G * mesh.G,
                            skeletonB * slot.B * mesh.B, a);
                    }

                    float[] uvs = mesh.UVs;
                    VertexPositionColorTexture[] itemVertices = item.vertices;
                    for (int ii = 0, v = 0; v < vertexCount; ii++, v += 2)
                    {
                        itemVertices[ii].Color               = color;
                        itemVertices[ii].Position.X          = vertices[v];
                        itemVertices[ii].Position.Y          = vertices[v + 1];
                        itemVertices[ii].Position.Z          = 0;
                        itemVertices[ii].TextureCoordinate.X = uvs[v];
                        itemVertices[ii].TextureCoordinate.Y = uvs[v + 1];
                    }
                }
                else if (attachment is SkinnedMeshAttachment)
                {
                    SkinnedMeshAttachment mesh = (SkinnedMeshAttachment)attachment;
                    int vertexCount            = mesh.UVs.Length;
                    if (vertices.Length < vertexCount)
                    {
                        vertices = new float[vertexCount];
                    }
                    mesh.ComputeWorldVertices(x, y, slot, vertices);

                    int[]    triangles = mesh.Triangles;
                    MeshItem item      = batcher.NextItem(vertexCount, triangles.Length);
                    item.triangles = triangles;

                    AtlasRegion region = (AtlasRegion)mesh.RendererObject;
                    item.texture = (Texture2D)region.page.rendererObject;

                    Color color;
                    float a = skeletonA * slot.A * mesh.A;
                    if (PremultipliedAlpha)
                    {
                        color = new Color(
                            skeletonR * slot.R * mesh.R * a,
                            skeletonG * slot.G * mesh.G * a,
                            skeletonB * slot.B * mesh.B * a, a);
                    }
                    else
                    {
                        color = new Color(
                            skeletonR * slot.R * mesh.R,
                            skeletonG * slot.G * mesh.G,
                            skeletonB * slot.B * mesh.B, a);
                    }

                    float[] uvs = mesh.UVs;
                    VertexPositionColorTexture[] itemVertices = item.vertices;
                    for (int ii = 0, v = 0; v < vertexCount; ii++, v += 2)
                    {
                        itemVertices[ii].Color               = color;
                        itemVertices[ii].Position.X          = vertices[v];
                        itemVertices[ii].Position.Y          = vertices[v + 1];
                        itemVertices[ii].Position.Z          = 0;
                        itemVertices[ii].TextureCoordinate.X = uvs[v];
                        itemVertices[ii].TextureCoordinate.Y = uvs[v + 1];
                    }
                }
            }

            batcher.End();

            if (DebugBones || DebugSlots)
            {
                if (DebugSlots)
                {
                    for (int i = 0; i < Skeleton.Slots.Count; ++i)
                    {
                        var slot = Skeleton.Slots[i];

                        if (slot.Attachment == null)
                        {
                            continue;
                        }

                        var verticesCount = 0;
                        var worldVertices = new float[1000]; // Max number of vertices per mesh.
                        if (slot.Attachment is RegionAttachment)
                        {
                            var attachment = (RegionAttachment)slot.Attachment;
                            attachment.ComputeWorldVertices(Skeleton.X, Skeleton.Y, slot.bone, worldVertices);
                            verticesCount = 8;
                        }
                        else if (slot.Attachment is MeshAttachment)
                        {
                            var mesh = (MeshAttachment)slot.Attachment;
                            mesh.ComputeWorldVertices(Skeleton.X, Skeleton.Y, slot, worldVertices);
                            verticesCount = mesh.Vertices.Length;
                        }
                        else if (slot.Attachment is SkinnedMeshAttachment)
                        {
                            var mesh = (SkinnedMeshAttachment)slot.Attachment;
                            mesh.ComputeWorldVertices(Skeleton.X, Skeleton.Y, slot, worldVertices);
                            verticesCount = mesh.UVs.Length;
                        }
                        else
                        {
                            continue;
                        }

                        CCPoint[] slotVertices = new CCPoint[verticesCount / 2];

                        for (int ii = 0, si = 0; ii < verticesCount; ii += 2, si++)
                        {
                            slotVertices[si].X = worldVertices[ii] * ScaleX;
                            slotVertices[si].Y = worldVertices[ii + 1] * ScaleY;
                        }

                        CCDrawingPrimitives.Begin();
                        CCDrawingPrimitives.DrawPoly(slotVertices, verticesCount / 2, true, DebugSlotColor);
                        CCDrawingPrimitives.End();
                    }
                }

                if (DebugBones)
                {
                    // Bone lengths.
                    for (int i = 0; i < Skeleton.Bones.Count; i++)
                    {
                        Bone bone = Skeleton.Bones[i];
                        x = bone.Data.Length * bone.M00 + bone.WorldX;
                        y = bone.Data.Length * bone.M10 + bone.WorldY;

                        CCDrawingPrimitives.Begin();
                        CCDrawingPrimitives.DrawLine(new CCPoint(bone.WorldX, bone.WorldY), new CCPoint(x, y), DebugJointColor);
                        CCDrawingPrimitives.End();
                    }

                    // Bone origins.
                    for (int i = 0; i < Skeleton.Bones.Count; i++)
                    {
                        Bone bone = Skeleton.Bones[i];
                        CCDrawingPrimitives.Begin();
                        CCDrawingPrimitives.DrawPoint(new CCPoint(bone.WorldX, bone.WorldY), 4, DebugBoneColor);
                        CCDrawingPrimitives.End();
                    }
                }
            }
        }
Exemplo n.º 21
0
        public override void Draw()
        {
            base.Draw();

            CCApplication app = CCApplication.SharedApplication;
            CCSize        s   = CCDirector.SharedDirector.WinSize;

            CCDrawingPrimitives.Begin();

            // draw a simple line
            CCDrawingPrimitives.DrawLine(new CCPoint(0, 0), new CCPoint(s.Width, s.Height),
                                         new CCColor4B(255, 255, 255, 255));

            // line: color, width, aliased
            CCDrawingPrimitives.DrawLine(new CCPoint(0, s.Height), new CCPoint(s.Width, 0),
                                         new CCColor4B(255, 0, 0, 255));

            // draw big point in the center
            CCDrawingPrimitives.DrawPoint(new CCPoint(s.Width / 2, s.Height / 2), 64, new CCColor4B(0, 0, 255, 128));

            // draw 4 small points
            CCPoint[] points = { new CCPoint(60, 60), new CCPoint(70, 70), new CCPoint(60, 70), new CCPoint(70, 60) };
            CCDrawingPrimitives.DrawPoints(points, 4, 4, new CCColor4B(0, 255, 255, 255));

            // draw a green circle with 10 segments
            CCDrawingPrimitives.DrawCircle(new CCPoint(s.Width / 2, s.Height / 2), 100, 0, 10, false,
                                           new CCColor4B(0, 255, 0, 255));

            // draw a green circle with 50 segments with line to center
            CCDrawingPrimitives.DrawCircle(new CCPoint(s.Width / 2, s.Height / 2), 50, CCMacros.CCDegreesToRadians(90),
                                           50, true, new CCColor4B(0, 255, 255, 255));


            // draw an arc within rectangular region
            CCDrawingPrimitives.DrawArc(new CCRect(200, 200, 100, 200), 0, 180,
                                        new CCColor4B(Microsoft.Xna.Framework.Color.AliceBlue));

            // draw an ellipse within rectangular region
            CCDrawingPrimitives.DrawEllipse(new CCRect(500, 200, 100, 200), new CCColor4B(255, 0, 0, 255));

            // draw an arc within rectangular region
            CCDrawingPrimitives.DrawPie(new CCRect(350, 0, 100, 100), 20, 100,
                                        new CCColor4B(Microsoft.Xna.Framework.Color.AliceBlue));

            // draw an arc within rectangular region
            CCDrawingPrimitives.DrawPie(new CCRect(347, -5, 100, 100), 120, 260,
                                        new CCColor4B(Microsoft.Xna.Framework.Color.Aquamarine));

            // open yellow poly
            CCPoint[] vertices =
            {
                new CCPoint(0,  0), new CCPoint(50, 50), new CCPoint(100, 50), new CCPoint(100, 100),
                new CCPoint(50, 100)
            };
            CCDrawingPrimitives.DrawPoly(vertices, 5, false, new CCColor4B(255, 255, 0, 255));

            // filled poly
            CCPoint[] filledVertices =
            {
                new CCPoint(0,  120), new CCPoint(50, 120), new CCPoint(50, 170),
                new CCPoint(25, 200), new CCPoint(0, 170)
            };
            CCDrawingPrimitives.DrawSolidPoly(filledVertices, 5, new CCColor4B(128, 128, 255, 255));

            // closed purble poly
            CCPoint[] vertices2 = { new CCPoint(30, 130), new CCPoint(30, 230), new CCPoint(50, 200) };
            CCDrawingPrimitives.DrawPoly(vertices2, 3, true, new CCColor4B(255, 0, 255, 255));

            // draw quad bezier path
            CCDrawingPrimitives.DrawQuadBezier(new CCPoint(0, s.Height),
                                               new CCPoint(s.Width / 2, s.Height / 2),
                                               new CCPoint(s.Width, s.Height),
                                               50,
                                               new CCColor4B(255, 0, 255, 255));

            // draw cubic bezier path
            CCDrawingPrimitives.DrawCubicBezier(new CCPoint(s.Width / 2, s.Height / 2),
                                                new CCPoint(s.Width / 2 + 30, s.Height / 2 + 50),
                                                new CCPoint(s.Width / 2 + 60, s.Height / 2 - 50),
                                                new CCPoint(s.Width, s.Height / 2), 100,
                                                new CCColor4B(255, 0, 255, 255));

            //draw a solid polygon
            CCPoint[] vertices3 =
            {
                new CCPoint(60, 160), new CCPoint(70, 190), new CCPoint(100, 190),
                new CCPoint(90, 160)
            };
            CCDrawingPrimitives.DrawSolidPoly(vertices3, 4, new CCColor4B(255, 255, 0, 255));

            CCDrawingPrimitives.End();
        }
Exemplo n.º 22
0
        public override void draw()
        {
            base.draw();

            CCApplication app = CCApplication.sharedApplication();
            CCSize        s   = CCDirector.sharedDirector().getWinSize();

            // draw a simple line
            // The default state is:
            // Line Width: 1
            // color: 255,255,255,255 (white, non-transparent)
            // Anti-Aliased
            //glEnable(GL_LINE_SMOOTH);
            CCDrawingPrimitives.ccDrawLine(new CCPoint(0, 0), new CCPoint(s.width, s.height), new ccColor4F(255, 255, 255, 255));

            // line: color, width, aliased
            // glLineWidth > 1 and GL_LINE_SMOOTH are not compatible
            // GL_SMOOTH_LINE_WIDTH_RANGE = (1,1) on iPhone
            //glDisable(GL_LINE_SMOOTH);
            //glLineWidth( 5.0f );
            /*glColor4ub(255,0,0,255);*/
            //glColor4f(1.0, 0.0, 0.0, 1.0);
            CCDrawingPrimitives.ccDrawLine(new CCPoint(0, s.height), new CCPoint(s.width, 0), new ccColor4F(255, 0, 0, 255));

            // TIP:
            // If you are going to use always the same color or width, you don't
            // need to call it before every draw
            //
            // Remember: OpenGL is a state-machine.

            // draw big point in the center
            //glPointSize(64);
            /*glColor4ub(0,0,255,128);*/
            //glColor4f(0.0, 0.0, 1.0, 0.5);
            //ccDrawPoint( CCPointMake(s.width / 2, s.height / 2) );

            // draw 4 small points
            CCPoint[] points = { new CCPoint(60, 60), new CCPoint(70, 70), new CCPoint(60, 70), new CCPoint(70, 60) };
            //glPointSize(4);
            /*glColor4ub(0,255,255,255);*/
            //glColor4f(0.0, 1.0, 1.0, 1.0);
            //ccDrawPoints( points, 4);

            // draw a green circle with 10 segments
            //glLineWidth(16);
            /*glColor4ub(0, 255, 0, 255);*/
            //glColor4f(0.0, 1.0, 0.0, 1.0);
            CCDrawingPrimitives.ccDrawCircle(new CCPoint(s.width / 2, s.height / 2), 100, 0, 10, false, new ccColor4B(0, 255, 0, 255));

            // draw a green circle with 50 segments with line to center
            //glLineWidth(2);
            /*glColor4ub(0, 255, 255, 255);*/
            //glColor4f(0.0, 1.0, 1.0, 1.0);
            CCDrawingPrimitives.ccDrawCircle(new CCPoint(s.width / 2, s.height / 2), 50, ccMacros.CC_DEGREES_TO_RADIANS(90), 50, true, new ccColor4B(0, 255, 255, 255));

            // open yellow poly
            /*glColor4ub(255, 255, 0, 255);*/
            //glColor4f(1.0, 1.0, 0.0, 1.0);
            //glLineWidth(10);
            CCPoint[] vertices = { new CCPoint(0, 0), new CCPoint(50, 50), new CCPoint(100, 50), new CCPoint(100, 100), new CCPoint(50, 100) };
            CCDrawingPrimitives.ccDrawPoly(vertices, 5, false, new ccColor4F(255, 255, 0, 255));

            // closed purble poly
            /*glColor4ub(255, 0, 255, 255);*/
            //glColor4f(1.0, 0.0, 1.0, 1.0);
            //glLineWidth(2);
            CCPoint[] vertices2 = { new CCPoint(30, 130), new CCPoint(30, 230), new CCPoint(50, 200) };
            CCDrawingPrimitives.ccDrawPoly(vertices2, 3, true, new ccColor4F(255, 0, 255, 255));

            // draw quad bezier path
            CCDrawingPrimitives.ccDrawQuadBezier(new CCPoint(0, s.height),
                                                 new CCPoint(s.width / 2, s.height / 2),
                                                 new CCPoint(s.width, s.height),
                                                 50,
                                                 new ccColor4F(255, 255, 0, 255));

            // draw cubic bezier path
            CCDrawingPrimitives.ccDrawCubicBezier(new CCPoint(s.width / 2, s.height / 2),
                                                  new CCPoint(s.width / 2 + 30, s.height / 2 + 50),
                                                  new CCPoint(s.width / 2 + 60, s.height / 2 - 50),
                                                  new CCPoint(s.width, s.height / 2), 100,
                                                  new ccColor4F(255, 0, 255, 255));

            // restore original values
            //glLineWidth(1);
            /*glColor4ub(255,255,255,255);*/
            //glColor4f(1.0, 1.0, 1.0, 1.0);
            //glPointSize(1);
        }
Exemplo n.º 23
0
        protected override void Draw()
        {
            base.Draw();

            CCSize size = Layer.VisibleBoundsWorldspace.Size;

            var visibleRect = VisibleBoundsWorldspace;

            CCDrawingPrimitives.Begin();


            // *NOTE* Using the Director.ContentScaleFactor for now until we work something out with the initialization
            // CCDrawPriitives should be able to do this converstion themselves.

            // draw a simple line
            // The default state is:
            // Line Width: 1
            // color: 255,255,255,255 (white, non-transparent)
            // Anti-Aliased
            //  glEnable(GL_LINE_SMOOTH);
            CCDrawingPrimitives.LineWidth = 1;
            CCDrawingPrimitives.DrawLine(visibleRect.LeftBottom(), visibleRect.RightTop());

            // line: color, width, aliased
            CCDrawingPrimitives.LineWidth = 5;
            CCDrawingPrimitives.DrawColor = CCColor4B.Red;
            CCDrawingPrimitives.DrawLine(visibleRect.LeftTop(), visibleRect.RightBottom());

            // TIP:
            // If you are going to use always thde same color or width, you don't
            // need to call it before every draw
            //

            // draw big point in the center
            CCDrawingPrimitives.PointSize = 64;
            CCDrawingPrimitives.DrawColor = new CCColor4B(0, 0, 255, 128);
            CCDrawingPrimitives.DrawPoint(visibleRect.Center());

            // draw 4 small points
            CCPoint[] points = { new CCPoint(60, 60), new CCPoint(70, 70), new CCPoint(60, 70), new CCPoint(70, 60) };

            CCDrawingPrimitives.PointSize = 8;
            CCDrawingPrimitives.DrawColor = new CCColor4B(0, 255, 255, 255);
            CCDrawingPrimitives.DrawPoints(points);

            // draw a green circle with 10 segments
            CCDrawingPrimitives.LineWidth = 16;
            CCDrawingPrimitives.DrawColor = CCColor4B.Green;
            CCDrawingPrimitives.DrawCircle(visibleRect.Center, 100, 0, 10, false);


            // draw a green circle with 50 segments with line to center
            CCDrawingPrimitives.LineWidth = 2;
            CCDrawingPrimitives.DrawColor = new CCColor4B(0, 255, 255, 255);
            CCDrawingPrimitives.DrawCircle(visibleRect.Center, 50, CCMacros.CCDegreesToRadians(45), 50, true);


            // draw a pink solid circle with 50 segments
            CCDrawingPrimitives.LineWidth = 2;
            CCDrawingPrimitives.DrawColor = new CCColor4B(255, 0, 255, 255);
            CCDrawingPrimitives.DrawSolidCircle(visibleRect.Center + new CCPoint(140, 0), 40, CCMacros.CCDegreesToRadians(90), 50);


            // draw an arc within rectangular region
            CCDrawingPrimitives.LineWidth = 5;
            CCDrawingPrimitives.DrawArc(new CCRect(200, 100, 100, 200), 0, 180, CCColor4B.AliceBlue);

            // draw an ellipse within rectangular region
            CCDrawingPrimitives.DrawEllipse(new CCRect(100, 100, 100, 200), CCColor4B.Red);

            // draw an arc within rectangular region
            CCDrawingPrimitives.DrawPie(new CCRect(350, 0, 100, 100), 20, 100, CCColor4B.AliceBlue);

            // draw an arc within rectangular region
            CCDrawingPrimitives.DrawPie(new CCRect(347, -5, 100, 100), 120, 260, CCColor4B.Aquamarine);

            // open yellow poly
            CCPoint[] vertices =
            {
                new CCPoint(0,  0), new CCPoint(50, 50), new CCPoint(100, 50), new CCPoint(100, 100),
                new CCPoint(50, 100)
            };
            CCDrawingPrimitives.LineWidth = 10;
            CCDrawingPrimitives.DrawColor = CCColor4B.Yellow;
            CCDrawingPrimitives.DrawPoly(vertices, 5, false, new CCColor4B(255, 255, 0, 255));


            // filled poly
            CCDrawingPrimitives.LineWidth = 1;
            CCPoint[] filledVertices =
            {
                new CCPoint(0,  120), new CCPoint(50, 120), new CCPoint(50, 170),
                new CCPoint(25, 200), new CCPoint(0, 170)
            };
            CCDrawingPrimitives.DrawSolidPoly(filledVertices, new CCColor4F(0.5f, 0.5f, 1, 1));

            // closed purple poly
            CCDrawingPrimitives.LineWidth = 2;
            CCDrawingPrimitives.DrawColor = new CCColor4B(255, 0, 255, 255);
            CCPoint[] vertices2 = { new CCPoint(30, 130), new CCPoint(30, 230), new CCPoint(50, 200) };
            CCDrawingPrimitives.DrawPoly(vertices2, true);

            // draw quad bezier path
            CCDrawingPrimitives.DrawQuadBezier(new CCPoint(0, size.Height),
                                               visibleRect.Center,
                                               (CCPoint)visibleRect.Size,
                                               50,
                                               new CCColor4B(255, 0, 255, 255));

            // draw cubic bezier path
            CCDrawingPrimitives.DrawCubicBezier(visibleRect.Center,
                                                new CCPoint(size.Width / 2 + 30, size.Height / 2 + 50),
                                                new CCPoint(size.Width / 2 + 60, size.Height / 2 - 50),
                                                new CCPoint(size.Width, size.Height / 2), 100);

            //draw a solid polygon
            CCPoint[] vertices3 =
            {
                new CCPoint(60, 160), new CCPoint(70, 190), new CCPoint(100, 190),
                new CCPoint(90, 160)
            };
            CCDrawingPrimitives.DrawSolidPoly(vertices3, 4, new CCColor4F(1, 1, 0, 1));

            CCDrawingPrimitives.End();
        }