예제 #1
0
 void SolidCircle()
 {
     drawNode.DrawSolidCircle(
         pos: new CCPoint(100, 100),
         radius: 50,
         color: CCColor4B.Yellow);
 }
예제 #2
0
        protected override void AddedToScene()
        {
            base.AddedToScene ();

            // Use the bounds to layout the positioning of our drawable assets
            CCRect bounds = VisibleBoundsWorldspace;

            // construct a white circle
            CCDrawNode circle = new CCDrawNode();
            circle.DrawSolidCircle(new CCPoint(100.0f, 100.0f), 75.0f, new CCColor4B(255, 255, 255, 255));
            AddChild(circle);

            // Register for touch events
            var touchListener = new CCEventListenerTouchAllAtOnce ();
            touchListener.OnTouchesEnded = OnTouchesEnded;
            AddEventListener (touchListener, this);
        }
예제 #3
0
        public GameLayer()
        {
            drawNode = new CocosSharp.CCDrawNode();
            this.AddChild(drawNode);

            drawNode.PositionX = 100;
            drawNode.PositionY = 100;

            drawNode.DrawSolidCircle(CCPoint.Zero, 100, CCColor4B.Green);

            // Uncomment one of the following to see
            // an example of a given Draw call:

            CardinalSpline();

//			CatmullRom ();

//			Circle ();

//			CubicBezier ();

//			Ellipse ();

//			Line ();

//			LineList ();

//			Polygon ();

//			QuadBezier ();

//			Rect ();

//			Segment ();

//			SolidArc ();

//			SolidCircle ();

//			TriangleList ();

            Schedule((tick) =>
            {
                drawNode.PositionX++;
            });
        }
예제 #4
0
		public GameLayer ()
		{

			drawNodeRoot = new CCNode ();
			drawNodeRoot.PositionX = 500;
			drawNodeRoot.PositionY = 350;
			this.AddChild (drawNodeRoot);

			CCDrawNode circle;
			circle = new CCDrawNode ();
			circle.DrawSolidCircle (CCPoint.Zero, DefaultCircleRadius, CCColor4B.Red);
			drawNodeRoot.AddChild (circle);

			lineNode = new LineNode ();
			drawNodeRoot.AddChild (lineNode);

			variableLabel = new CCLabel ("Hello", "Arial", 46, CCLabelFormat.SystemFont);
			variableLabel.HorizontalAlignment = CCTextAlignment.Left;
			variableLabel.AnchorPoint = new CCPoint (0, 0);
			variableLabel.PositionX = 48;
			variableLabel.PositionY = 390;
			this.AddChild (variableLabel);


			easingLabel = new CCLabel ("Hello", "Arial", 46, CCLabelFormat.SystemFont);
			easingLabel.HorizontalAlignment = CCTextAlignment.Left;
			easingLabel.AnchorPoint = new CCPoint (0, 0);
			easingLabel.PositionX = 48;
			easingLabel.PositionY = 330;
			this.AddChild (easingLabel);


			inOutLabel = new CCLabel ("Hello", "Arial", 46, CCLabelFormat.SystemFont);
			inOutLabel.HorizontalAlignment = CCTextAlignment.Left;
			inOutLabel.AnchorPoint = new CCPoint (0, 0);
			inOutLabel.PositionX = 48;
			inOutLabel.PositionY = 270;
			this.AddChild (inOutLabel);



			UpdateLabels ();
		}
예제 #5
0
        /// <summary>
        /// Draws the border.
        /// </summary>
        /// <param name="borderPositions">The border positions.</param>
        /// <param name="color">The border color.</param>
        /// <param name="owner">The area owner.</param>
        public void DrawBorder(HashSet<PositionI> borderPositions, CCColor4B color, Account owner)
        {
            RemoveBorder(owner);
            if (borderPositions != null)
            {
                var border = new CCDrawNode();
                m_tileMap.TileLayersContainer.AddChild(border);
                m_drawNodes.Add(owner, border);

                var halfwidth = ClientConstants.TILE_HEX_IMAGE_WIDTH / 2.0f;
                var halfhight = ClientConstants.TILE_HEX_IMAGE_HEIGHT / 2.0f;
                // zentrieren der Grenzpunkte und zeichnen dieser
                foreach (var positionI in borderPositions)
                {
                    var centerPos = PositionHelper.CellToTile(positionI.CellPosition);
                    centerPos.X += halfwidth;
                    centerPos.Y -= halfhight;
                    border.DrawSolidCircle(centerPos, ClientConstants.TERRATORRY_BUILDING_BORDER_SIZE, color);
                }
            }
        }
예제 #6
0
        void AddSun()
        {
            circleNode = new CCDrawNode ();
            circleNode.DrawSolidCircle (CCPoint.Zero, 30.0f, CCColor4B.Yellow);
            AddChild (circleNode);

            sun = new CCParticleSun (CCPoint.Zero);
            sun.StartColor = new CCColor4F (CCColor3B.Red);
            sun.EndColor = new CCColor4F (CCColor3B.Yellow);
            AddChild (sun);
        }
예제 #7
0
        public override void OnEnter()
        {
            base.OnEnter(); 
            CCSize windowSize = Layer.VisibleBoundsWorldspace.Size;
            CCDrawNode draw = new CCDrawNode();
            AddChild(draw, 10);

            var s = windowSize;

            // Draw 10 circles
            for (int i = 0; i < 10; i++)
            {
                draw.DrawSolidCircle(s.Center, 10 * (10 - i),
                    new CCColor4F(CCRandom.Float_0_1(), CCRandom.Float_0_1(), CCRandom.Float_0_1(), 1));
            }

            // Draw polygons
            CCV3F_C4B[] points = new CCV3F_C4B[3];

            points[0].Colors = CCColor4B.Red;
            points[0].Colors.A = 127;

            points[1].Colors = CCColor4B.Green;
            points[1].Colors.A = 127;

            points[2].Colors = CCColor4B.Blue;
            points[2].Colors.A = 127;

            points[0].Vertices.X = windowSize.Height / 4;
            points[0].Vertices.Y = 0;

            points[1].Vertices.X = windowSize.Width;
            points[1].Vertices.Y = windowSize.Height / 5;

            points[2].Vertices.X = windowSize.Width / 3 * 2;
            points[2].Vertices.Y = windowSize.Height;

            draw.DrawTriangleList(points);

            // star poly (triggers buggs)
            {
                const float o = 80;
                const float w = 20;
                const float h = 50;
                CCPoint[] star = new CCPoint[]
                    {
                        new CCPoint(o + w, o - h), new CCPoint(o + w * 2, o),                           // lower spike
                        new CCPoint(o + w * 2 + h, o + w), new CCPoint(o + w * 2, o + w * 2),           // right spike
                    };

                draw.DrawPolygon(star, star.Length, new CCColor4F(1, 0, 0, 0.5f), 1, new CCColor4F(0, 0, 1, 1));
            }

            // star poly (doesn't trigger bug... order is important un tesselation is supported.
            {
                const float o = 180;
                const float w = 20;
                const float h = 50;
                var star = new CCPoint[]
                    {
                        new CCPoint(o, o), new CCPoint(o + w, o - h), new CCPoint(o + w * 2, o),        // lower spike
                        new CCPoint(o + w * 2 + h, o + w), new CCPoint(o + w * 2, o + w * 2),           // right spike
                        new CCPoint(o + w, o + w * 2 + h), new CCPoint(o, o + w * 2),                   // top spike
                        new CCPoint(o - h, o + w), // left spike
                    };

                draw.DrawPolygon(star, star.Length, new CCColor4F(1, 0, 0, 0.5f), 1, new CCColor4F(0, 0, 1, 1));
            }


            // Draw segment
            draw.DrawLine(new CCPoint(20, windowSize.Height), new CCPoint(20, windowSize.Height / 2), 10, new CCColor4F(0, 1, 0, 1), CCLineCap.Round);

            draw.DrawLine(new CCPoint(10, windowSize.Height / 2), new CCPoint(windowSize.Width / 2, windowSize.Height / 2), 40,
                new CCColor4F(1, 0, 1, 0.5f), CCLineCap.Round);
        }
예제 #8
0
        public override void OnEnter()
        {
            base.OnEnter(); 
            CCSize windowSize = Layer.VisibleBoundsWorldspace.Size;
            CCDrawNode draw = new CCDrawNode();
            AddChild(draw, 10);

			var s = windowSize;

            // Draw 10 circles
            for (int i = 0; i < 10; i++)
            {
				draw.DrawSolidCircle(s.Center, 10 * (10 - i),
                    new CCColor4F(CCRandom.Float_0_1(), CCRandom.Float_0_1(), CCRandom.Float_0_1(), 1));
            }

            // Draw polygons
            CCPoint[] points = new CCPoint[]
            {
                new CCPoint(windowSize.Height / 4, 0),
                new CCPoint(windowSize.Width, windowSize.Height / 5),
                new CCPoint(windowSize.Width / 3 * 2, windowSize.Height)
            };
            draw.DrawPolygon(points, points.Length, new CCColor4F(1.0f, 0, 0, 0.5f), 4, new CCColor4F(0, 0, 1, 1));
			
            // star poly (triggers buggs)
			{
	            const float o = 80;
	            const float w = 20;
	            const float h = 50;
	            CCPoint[] star = new CCPoint[]
	            {
	                new CCPoint(o + w, o - h), new CCPoint(o + w * 2, o),                           // lower spike
	                new CCPoint(o + w * 2 + h, o + w), new CCPoint(o + w * 2, o + w * 2),           // right spike
	            };

	            draw.DrawPolygon(star, star.Length, new CCColor4F(1, 0, 0, 0.5f), 1, new CCColor4F(0, 0, 1, 1));
			}

            // star poly (doesn't trigger bug... order is important un tesselation is supported.
            {
                const float o = 180;
                const float w = 20;
                const float h = 50;
                var star = new CCPoint[]
                {
                    new CCPoint(o, o), new CCPoint(o + w, o - h), new CCPoint(o + w * 2, o),        // lower spike
                    new CCPoint(o + w * 2 + h, o + w), new CCPoint(o + w * 2, o + w * 2),           // right spike
                    new CCPoint(o + w, o + w * 2 + h), new CCPoint(o, o + w * 2),                   // top spike
                    new CCPoint(o - h, o + w), // left spike
                };

                draw.DrawPolygon(star, star.Length, new CCColor4F(1, 0, 0, 0.5f), 1, new CCColor4F(0, 0, 1, 1));
            }


            // Draw segment
            draw.DrawLine(new CCPoint(20, windowSize.Height), new CCPoint(20, windowSize.Height / 2), 10, new CCColor4F(0, 1, 0, 1), CCLineCap.Round);

            draw.DrawLine(new CCPoint(10, windowSize.Height / 2), new CCPoint(windowSize.Width / 2, windowSize.Height / 2), 40,
                new CCColor4F(1, 0, 1, 0.5f), CCLineCap.Round);

            CCSize size = Layer.VisibleBoundsWorldspace.Size;

            var visibleRect = VisibleBoundsWorldspace;

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

            // draw cubic bezier path
            draw.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, 2, CCColor4B.Green);

            // draw an ellipse within rectangular region
            draw.DrawEllipse(new CCRect(100, 300, 100, 200), 8, CCColor4B.AliceBlue);

            var splinePoints = new List<CCPoint>();
            splinePoints.Add(new CCPoint(0, 0));
            splinePoints.Add(new CCPoint(50, 70));
            splinePoints.Add(new CCPoint(0, 140));
            splinePoints.Add(new CCPoint(100, 210));
            splinePoints.Add(new CCPoint(0, 280));
            splinePoints.Add(new CCPoint(150, 350));

            int numberOfSegments = 64;
            float tension = .05f;
            draw.DrawCardinalSpline(splinePoints, tension, numberOfSegments);

            draw.DrawSolidArc(
                pos: new CCPoint(350, windowSize.Height * 0.75f),
                radius: 100,
                startAngle: CCMathHelper.ToRadians(45),
                sweepAngle: CCMathHelper.Pi / 2, // this is in radians, clockwise
                color: CCColor4B.Aquamarine);


        }
예제 #9
0
        public override void OnEnter()
        {
            base.OnEnter(); 

            CCDrawNode circle = new CCDrawNode();
            circle.DrawSolidCircle(new CCPoint(150.0f, 150.0f), 75.0f, new CCColor4B(255, 255, 255, 255));

            CCRenderTexture rtm = new CCRenderTexture(new CCSize(200.0f, 200.0f), new CCSize(200.0f, 200.0f), CCSurfaceFormat.Color, CCDepthFormat.Depth24Stencil8);
            rtm.BeginWithClear(CCColor4B.Orange);
            circle.Visit(); // Draw to rendertarget
            rtm.End();

            // Create a new sprite from the render target texture
            var sprite = new CCSprite(rtm.Texture);
            sprite.Position = VisibleBoundsWorldspace.Center;


            AddChild(sprite);
        }
예제 #10
0
        public override void OnEnter()
        {
            base.OnEnter(); 

            CCDrawNode circle = new CCDrawNode();
            circle.DrawSolidCircle(new CCPoint(150.0f, 150.0f), 75.0f, new CCColor4B(255, 255, 255, 255));

            CCRenderTexture rtm = new CCRenderTexture(new CCSize(200.0f, 200.0f), new CCSize(200.0f, 200.0f), CCSurfaceFormat.Color, CCDepthFormat.Depth24Stencil8);

            rtm.BeginWithClear(CCColor4B.Orange);
            circle.Visit();
            rtm.End();

            // Make sure our children nodes get visited

            rtm.Sprite.Position = VisibleBoundsWorldspace.Center;
            rtm.Sprite.AnchorPoint = CCPoint.AnchorMiddle;


            AddChild(rtm.Sprite);
        }