public override void Setup() { var s = CCDirector.SharedDirector.WinSize; CCClippingNode clipper = new CCClippingNode(); clipper.Tag = kTagClipperNode; clipper.ContentSize = new CCSize(200, 200); clipper.AnchorPoint = new CCPoint(0.5f, 0.5f); clipper.Position = ContentSize.Center; clipper.RunAction(new CCRepeatForever(new CCRotateBy(1, 45))); AddChild(clipper); CCDrawNode stencil = new CCDrawNode(); CCPoint[] rectangle = { new CCPoint(0, 0), new CCPoint(clipper.ContentSize.Width, 0), new CCPoint(clipper.ContentSize.Width, clipper.ContentSize.Height), new CCPoint(0, clipper.ContentSize.Height), }; CCColor4F white = new CCColor4F(1, 1, 1, 1); stencil.DrawPolygon(rectangle, 4, white, 0, white); clipper.Stencil = stencil; CCSprite content = new CCSprite(TestResource.s_back2); content.Tag = kTagContentNode; content.AnchorPoint = new CCPoint(0.5f, 0.5f); content.Position = clipper.ContentSize.Center; clipper.AddChild(content); m_bScrolling = false; TouchEnabled = true; }
public override bool Init() { base.Init(); CCSize s = CCDirector.SharedDirector.WinSize; CCDrawNode draw = new CCDrawNode(); AddChild(draw, 10); // Draw 10 circles for (int i = 0; i < 10; i++) { draw.DrawDot(new CCPoint(s.Width / 2, s.Height / 2), 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(s.Height / 4, 0), new CCPoint(s.Width, s.Height / 5), new CCPoint(s.Width / 3 * 2, s.Height) }; draw.DrawPolygon(points, points.Length, new CCColor4F(1, 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 // {o +w, o+w*2+h}, {o,o+w*2}, // top spike // {o -h, o+w}, {o,o}, // left 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.DrawSegment(new CCPoint(20, s.Height), new CCPoint(20, s.Height / 2), 10, new CCColor4F(0, 1, 0, 1)); draw.DrawSegment(new CCPoint(10, s.Height / 2), new CCPoint(s.Width / 2, s.Height / 2), 40, new CCColor4F(1, 0, 1, 0.5f)); return true; }
protected virtual CCDrawNode Shape() { var shape = new CCDrawNode(); var triangle = new CCPoint[3]; triangle[0] = new CCPoint(-100, -100); triangle[1] = new CCPoint(100, -100); triangle[2] = new CCPoint(0, 100); shape.DrawPolygon(triangle, 3, new CCColor4F(0, 1, 0, 1), 0, new CCColor4F(0, 1, 0, 1)); return shape; }
public DrawPrimitivesWithRenderTextureTest() { CCSize s = CCDirector.SharedDirector.WinSize; CCRenderTexture text = new CCRenderTexture((int)s.Width, (int)s.Height); CCDrawNode draw = new CCDrawNode(); text.AddChild(draw, 10); text.Begin(); // Draw polygons CCPoint[] points = new CCPoint[] { new CCPoint(s.Height / 4, 0), new CCPoint(s.Width, s.Height / 5), new CCPoint(s.Width / 3 * 2, s.Height) }; draw.DrawPolygon(points, points.Length, new CCColor4F(1, 0, 0, 0.5f), 4, new CCColor4F(0, 0, 1, 1)); text.End(); AddChild(text, 24); }