protected override void AddedToScene() { base.AddedToScene(); var s = VisibleBoundsWorldspace.Size; var parent = new CCNode(); parent.Position = new CCPoint(s.Width / 2, s.Height / 2); AddChild(parent); var rectNode = new CCDrawNode(); CCPoint[] rectangle = new CCPoint [] { new CCPoint(-50, -50), new CCPoint(50, -50), new CCPoint(50, 50), new CCPoint(-50, 50) }; var white = new CCColor4F(1, 1, 1, 1); rectNode.DrawPolygon(rectangle, 4, white, 1, white); parent.AddChild(rectNode); }
public Bubble() { UniversalId++; id = UniversalId; random = new Random(); Scale = 0.5f; switch (random.Next(0, 5)) { case 0: color = color0; break; case 1: color = color1; break; case 2: color = color2; break; case 3: color = color3; break; case 4: color = color4; break; } colorF = new CCColor4F(color); var size = CCRandom.Next(25, 50); this.ContentSize = new CCSize(size, size); this.DrawSolidCircle(this.Position, (float)size, color); }
public Bubble(int maxColors, int maxGrowthTime) { _maxGrowthTime = maxGrowthTime; Id = _universalId++; Scale = 0.5f; BubbleColor = GetRandomColor(maxColors); ColorF = new CCColor4F(BubbleColor); int randomSize = CCRandom.Next(25, 50); ContentSize = new CCSize(randomSize, randomSize); DrawSolidCircle(Position, randomSize, BubbleColor); }
public void DrawRect(CCRect rect, CCColor4B fillColor, float borderWidth, CCColor4B borderColor) { float x1 = rect.MinX; float y1 = rect.MinY; float x2 = rect.MaxX; float y2 = rect.MaxY; CCPoint[] pt = new CCPoint[] { new CCPoint(x1, y1), new CCPoint(x2, y1), new CCPoint(x2, y2), new CCPoint(x1, y2) }; CCColor4F cf = new CCColor4F(fillColor.R / 255f, fillColor.G / 255f, fillColor.B / 255f, fillColor.A / 255f); CCColor4F bc = new CCColor4F(borderColor.R / 255f, borderColor.G / 255f, borderColor.B / 255f, borderColor.A / 255f); DrawPolygon(pt, 4, cf, borderWidth, bc); }
public override void Setup() { CCClippingNode clipper = new CCClippingNode() { Tag = kTagClipperNode }; clipper.ContentSize = new CCSize(200, 200); clipper.AnchorPoint = new CCPoint(0.5f, 0.5f); 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(0, 0, 0, 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); clipper.AddChild(content); content.RunAction(new CCRepeatForever(new CCRotateBy(1, 45))); m_bScrolling = false; // Register Touch Event var touchListener = new CCEventListenerTouchAllAtOnce(); touchListener.OnTouchesBegan = onTouchesBegan; touchListener.OnTouchesMoved = onTouchesMoved; touchListener.OnTouchesEnded = onTouchesEnded; AddEventListener(touchListener); }
protected override void OnHandlePropTypeColor4FVar(CCNode node, CCNode parent, string propertyName, CCColor4F[] colorVar, CCBReader reader) { if (propertyName == PROPERTY_STARTCOLOR) { ((CCParticleSystemQuad) node).StartColor = (colorVar[0]); ((CCParticleSystemQuad) node).StartColorVar = (colorVar[1]); } else if (propertyName == PROPERTY_ENDCOLOR) { ((CCParticleSystemQuad) node).EndColor = (colorVar[0]); ((CCParticleSystemQuad) node).EndColorVar = (colorVar[1]); } else { base.OnHandlePropTypeColor4FVar(node, parent, propertyName, colorVar, reader); } }
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 void doTest() { CCSize s = Layer.VisibleBoundsWorldspace.Size; var particleSystem = (CCParticleSystemQuad)GetChildByTag(PerformanceParticleTest.kTagParticleSystem); // duration particleSystem.Duration = -1; // gravity particleSystem.Gravity = (new CCPoint(0, -90)); // angle particleSystem.Angle = 90; particleSystem.AngleVar = 0; // radial particleSystem.RadialAccel = (0); particleSystem.RadialAccelVar = (0); // speed of particles particleSystem.Speed = (180); particleSystem.SpeedVar = (50); // emitter position particleSystem.Position = new CCPoint(s.Width / 2, 100); particleSystem.PositionVar = new CCPoint(s.Width / 2, 0); // life of particles particleSystem.Life = 2.0f; particleSystem.LifeVar = 1; // emits per frame particleSystem.EmissionRate = particleSystem.TotalParticles / particleSystem.Life; // color of particles CCColor4F startColor = new CCColor4F { R = 0.5f, G = 0.5f, B = 0.5f, A = 1.0f }; particleSystem.StartColor = startColor; CCColor4F startColorVar = new CCColor4F { R = 0.5f, G = 0.5f, B = 0.5f, A = 1.0f }; particleSystem.StartColorVar = startColorVar; CCColor4F endColor = new CCColor4F { R = 0.1f, G = 0.1f, B = 0.1f, A = 0.2f }; particleSystem.EndColor = endColor; CCColor4F endColorVar = new CCColor4F { R = 0.1f, G = 0.1f, B = 0.1f, A = 0.2f }; particleSystem.EndColorVar = endColorVar; // size, in pixels particleSystem.EndSize = 64.0f; particleSystem.StartSize = 64.0f; particleSystem.EndSizeVar = 0; particleSystem.StartSizeVar = 0; // additive particleSystem.BlendAdditive = false; }
public void DrawRoundedLine(CCPoint from, CCPoint to, float radius, CCColor4F fill) => DrawRoundedLine(from, to, radius, fill, 0, CCColor4B.Transparent.ToColor4F());
public void DrawRoundedLine(CCPoint from, CCPoint to, float radius, CCColor4F fill, float borderThickness, CCColor4F borderColor) { DrawNode.DrawSegment(from, to, radius + borderThickness, borderColor); DrawNode.DrawSegment(from, to, radius, fill); }