private void CreateHowtoLabel() { float backgroundWidth = howToImage.ScaledContentSize.Width; const float backgroundHeight = 36; labelBackground = new CCDrawNode (); var rect = new CCRect ( -backgroundWidth / 2.0f, -backgroundHeight / 2.0f, backgroundWidth , backgroundHeight ); labelBackground.DrawRect ( rect, CCColor4B.Black); labelBackground.PositionX = ContentSize.Center.X; labelBackground.PositionY = 74; mainLayer.AddChild (labelBackground); howToLabel = new CCLabel( "Touch and move on the left side of the screen to move.\nTap on the right side to jump.", "fonts/Aldrich-Regular.ttf", 12, CCLabelFormat.SystemFont); howToLabel.PositionX = ContentSize.Center.X; howToLabel.Scale = .5f; howToLabel.PositionY = 74; howToLabel.HorizontalAlignment = CCTextAlignment.Center; howToLabel.VerticalAlignment = CCVerticalTextAlignment.Center; howToLabel.IsAntialiased = false; mainLayer.AddChild (howToLabel); }
/* * TL TR * 0----1 0,1,2,3 = index offsets for vertex indices * | /| * | / | * | / | * |/ | * 2----3 * BL BR */ void GenerateGradient(CCSize textureSizeInPixels) { var gradientNode = new CCDrawNode(); var gradientAlpha = new CCColor4B(0, 0, 0,(byte)(0.7f * 255f)); CCV3F_C4B[] vertices = new CCV3F_C4B[6]; // Left triangle TL - 0 vertices[0].Vertices = new CCVertex3F(0, textureSizeInPixels.Height, 0); vertices[0].Colors = CCColor4B.Transparent; // Left triangle BL - 2 vertices[1].Vertices = new CCVertex3F(0, 0, 0); vertices[1].Colors = gradientAlpha; // Left triangle TR - 1 vertices[2].Vertices = new CCVertex3F(textureSizeInPixels.Width, textureSizeInPixels.Height, 0); vertices[2].Colors = CCColor4B.Transparent; // Right triangle BL - 2 vertices[3].Vertices = new CCVertex3F(0, 0, 0); vertices[3].Colors = gradientAlpha; // Right triangle BR - 3 vertices[4].Vertices = new CCVertex3F(textureSizeInPixels.Width, 0, 0); vertices[4].Colors = gradientAlpha; // Right triangle TR - 1 vertices[5].Vertices = new CCVertex3F(textureSizeInPixels.Width, textureSizeInPixels.Height, 0); vertices[5].Colors = CCColor4B.Transparent; gradientNode.DrawTriangleList(vertices); gradientNode.Visit(); }
public LabelFNTOldNew() { // CCLabel Bitmap Font label1 = new CCLabel("Bitmap Font Label Test", "fonts/arial-unicode-26.fnt"); label1.Scale = 2; label1.Color = CCColor3B.White; AddChild(label1); label2 = new CCLabelBMFont("Bitmap Font Label Test", "fonts/arial-unicode-26.fnt"); label2.Scale = 2; label2.Color = CCColor3B.Red; AddChild(label2); drawNode = new CCDrawNode(); AddChild(drawNode); var touchListener = new CCEventListenerTouchAllAtOnce(); touchListener.OnTouchesEnded = (touches, touchEvent) => { var location = touches[0].Location; if (label1.BoundingBoxTransformedToWorld.ContainsPoint(location)) CCLog.Log("Hit"); }; AddEventListener(touchListener); }
public override void OnEnter() { base.OnEnter(); var windowSize = Layer.VisibleBoundsWorldspace.Size; CCRenderTexture text = new CCRenderTexture(windowSize,windowSize); text.Sprite.Position = windowSize.Center; AddChild(text.Sprite, 24); CCDrawNode draw = new CCDrawNode(); // 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, 0, 0, 0.5f), 4, new CCColor4F(0, 0, 1, 1)); draw.AnchorPoint = CCPoint.AnchorLowerLeft; text.Begin(); draw.Visit(); text.End(); }
public LabelSFOldNew() { // CCLabel SpriteFont label1 = new CCLabel("SpriteFont Label Test", "arial", 48, CCLabelFormat.SpriteFont); AddChild(label1); label2 = new CCLabelTtf("SpriteFont Label Test", "arial", 48); label2.Color = CCColor3B.Red; label2.AnchorPoint = CCPoint.AnchorMiddle; AddChild(label2); drawNode = new CCDrawNode(); AddChild(drawNode); var touchListener = new CCEventListenerTouchAllAtOnce(); touchListener.OnTouchesEnded = (touches, touchEvent) => { var location = touches[0].Location; if (label1.BoundingBoxTransformedToWorld.ContainsPoint(location)) CCLog.Log("Hit"); }; AddEventListener(touchListener); }
protected override void AddedToScene() { base.AddedToScene(); this.possibleMoves = new CCDrawNode(); this.Parent.AddChild(this.possibleMoves, 1); drawNode = new CCDrawNode(); this.Parent.AddChild(drawNode, 1); }
private void CreateDebugGraphic() { debugGraphic = new CCDrawNode (); debugGraphic.DrawRect ( new CCRect (-width/2, -height/2, width, height), fillColor: new CCColor4B(180, 180, 180, 180)); this.AddChild (debugGraphic); }
public Ball(float x, float y, float r, CCColor4B c) { this.x = x; this.y = y; this.r = r; this.color = c; location = new CCPoint (x , y); circle = new CCDrawNode (); drawCircle (); }
/* * TL TR * 0----1 0,1,2,3 = index offsets for vertex indices * | /| * | / | * | / | * |/ | * 2----3 * BL BR */ void GenerateStripes (CCSize textureSizeInPixels, CCColor4B c2, int numberOfStripes) { var gradientNode = new CCDrawNode(); // Layer 1: Stripes CCV3F_C4B[] vertices = new CCV3F_C4B[numberOfStripes*6]; var textureWidth = textureSizeInPixels.Width; var textureHeight = textureSizeInPixels.Height; int nVertices = 0; float x1 = -textureHeight; float x2; float y1 = textureHeight; float y2 = 0; float dx = textureWidth / numberOfStripes * 2; float stripeWidth = dx/2; for (int i=0; i<numberOfStripes; i++) { x2 = x1 + textureHeight; // Left triangle TL - 0 vertices[nVertices].Vertices = new CCVertex3F(x1, y1, 0); vertices[nVertices++].Colors = c2; // Left triangle BL - 2 vertices[nVertices].Vertices = new CCVertex3F(x1+stripeWidth, y1, 0); vertices[nVertices++].Colors = c2; // Left triangle TR - 1 vertices[nVertices].Vertices = new CCVertex3F(x2, y2, 0); vertices[nVertices++].Colors = c2; // Right triangle BL - 2 vertices[nVertices].Vertices = vertices[nVertices-2].Vertices; vertices[nVertices++].Colors = c2; // Right triangle BR - 3 vertices[nVertices].Vertices = vertices[nVertices-2].Vertices; vertices[nVertices++].Colors = c2; // Right triangle TR - 1 vertices[nVertices].Vertices = new CCVertex3F(x2+stripeWidth, y2, 0); vertices[nVertices++].Colors = c2; x1 += dx; } gradientNode.DrawTriangleList(vertices); gradientNode.Visit(); }
private void CreateMusicPlayButton() { musicPlayButton = new CCDrawNode(); MakePlayGraphic(musicPlayButton); musicPlayButton.PositionX = musicLabel.PositionX + musicLabel.BoundingBox.Size.Width; musicPlayButton.PositionY = musicLabel.PositionY - 18; this.AddChild(musicPlayButton); }
public override void OnEnter () { base.OnEnter (); var s = Layer.VisibleBoundsWorldspace.Size; var drawNode = new CCDrawNode(); drawNode.DrawLine( new CCPoint(0, s.Height/2), new CCPoint(s.Width, s.Height/2), new CCColor4F(1.0f, 1.0f, 1.0f, 1.0f) ); drawNode.DrawLine( new CCPoint(s.Width/2, 0), new CCPoint(s.Width/2, s.Height), new CCColor4F(1.0f, 1.0f, 1.0f, 1.0f) ); AddChild(drawNode, -1); }
public LabelFNTBounds () { Color = new CCColor3B(128, 128, 128); Opacity = 255; label = new CCLabel("Testing Glyph Designer", "fonts/boundsTestFont.fnt"); label.LabelFormat.Alignment = CCTextAlignment.Center; AddChild(label); drawNode = new CCDrawNode(); AddChild(drawNode); }
public SolidRectangle(float width, float height) { Polygon = Polygon.CreateRectangle(width, height); var graphic = new CCDrawNode(); graphic.DrawRect( new CCRect(-width / 2, -height / 2, width, height), fillColor: CCColor4B.Blue); this.AddChild(graphic); this.AddChild(Polygon); }
public override void OnEnter() { base.OnEnter(); CreateGeometry(); var draw = new CCDrawNode(); draw.BlendFunc = CCBlendFunc.NonPremultiplied; AddChild(draw, 10); draw.DrawTriangleList(drawBuffer.TriangleVertices.ToArray()); draw.DrawLineList(drawBuffer.LineVertices.ToArray()); }
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++; }); }
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); }
public ScoreText () { background = new CCDrawNode (); const int width = 115; const int height = 27; background.DrawRect (new CCRect (-5, -height , width, height), new CCColor4B (100, 100, 100)); this.AddChild (background); label = new CCLabel ("Score: 9999", "Arial", 20, CCLabelFormat.SystemFont); label.AnchorPoint = new CCPoint(0, 1); this.AddChild (label); }
public GameScene (CCGameView gameView) : base(gameView) { var layer = new CCLayer (); this.AddLayer (layer); circle = new CCDrawNode (); layer.AddChild (circle); circle.DrawCircle ( // The center to use when drawing the circle, // relative to the CCDrawNode: new CCPoint (0, 0), radius:15, color:CCColor4B.White); circle.PositionX = 20; circle.PositionY = 50; }
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 (); }
public GameLayer () { drawNode = new CCDrawNode (); this.AddChild (drawNode); drawNode.PositionX = 100; drawNode.PositionY = 100; // Uncomment one of the following to see // an example of a given Draw call: CardinalSpline (); // CatmullRom (); // Circle (); // CubicBezier (); // Dot (); // Ellipse (); // Line (); // LineList (); // Polygon (); // QuadBezier (); // Rect (); // Segment (); // SolidArc (); // SolidCircle (); // TriangleList (); }
public RenderTextureDrawNode() { canvasNode = new CCDrawNode(); AddChild(canvasNode); // Save image menu CCMenuItemFont.FontSize = 16; CCMenuItemFont.FontName = "arial"; CCMenuItem item1 = new CCMenuItemFont("Save Image", SaveImage); CCMenuItem item2 = new CCMenuItemFont("Clear", ClearImage); saveImageMenu = new CCMenu(item1, item2); AddChild(saveImageMenu); // Register for touch events var touchListener = new CCEventListenerTouchAllAtOnce(); touchListener.OnTouchesEnded = OnTouchesEnded; touchListener.OnTouchesBegan = OnTouchesBegan; touchListener.OnTouchesMoved = OnTouchesMoved; AddEventListener(touchListener, this); }
public override void OnEnter() { base.OnEnter(); var effect = new CCSequence(new CCDelayTime (2.0f), new CCShaky3D(5.0f, new CCGridSize(5, 5), 16, false)); // cleanup contentLayer.RemoveChild(bgNode, true); // background var layer = new CCDrawNode(); layer.Color = CCColor3B.Red; layer.Opacity = 255; layer.DrawRect(VisibleBoundsWorldspace); AddChild(layer, -10); var sprite = new CCSprite("Images/grossini"); sprite.Position = new CCPoint(50, 80); layer.AddChild(sprite, 10); // foreground var layer2BaseGrid = new CCNodeGrid (); var layer2 = new CCDrawNode(); layer2.Color = CCColor3B.Green; layer2.Opacity = 255; layer2.DrawRect(VisibleBoundsWorldspace); var fog = new CCSprite("Images/Fog"); var bf = new CCBlendFunc {Source = CCOGLES.GL_SRC_ALPHA, Destination = CCOGLES.GL_ONE_MINUS_SRC_ALPHA}; fog.BlendFunc = bf; layer2.AddChild(fog, 1); AddChild(layer2BaseGrid, 1); layer2BaseGrid.AddChild (layer2); layer2BaseGrid.RepeatForever(effect); }
protected override void AddedToScene() { base.AddedToScene(); // Use the bounds to layout the positioning of our drawable assets CCRect bounds = VisibleBoundsWorldspace; // point to rotate around origin = bounds.Center; // Draw a magenta circle at our origin var originNode = new CCDrawNode(); originNode.DrawDot(origin, 10, new CCColor4F(CCColor4B.Magenta)); AddChild(originNode); PositionMonkey(); // Register for touch events var touchListener = new CCEventListenerTouchAllAtOnce(); touchListener.OnTouchesEnded = OnTouchesEnded; AddEventListener(touchListener, this); }
protected void DrawPolygon(Dictionary<string, string> dict, CCDrawNode draw) { List<CCPoint> points = ParsePoints(dict["points"]); draw.DrawPolygon(points.ToArray(), points.Count, new CCColor4B(0, 0, 0, 0), 1.0f, new CCColor4B(255, 255, 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.DrawDot(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.DrawSegment(new CCPoint(20, windowSize.Height), new CCPoint(20, windowSize.Height / 2), 10, new CCColor4F(0, 1, 0, 1)); draw.DrawSegment(new CCPoint(10, windowSize.Height / 2), new CCPoint(windowSize.Width / 2, windowSize.Height / 2), 40, new CCColor4F(1, 0, 1, 0.5f)); }
public DrawNodeTest() { draw = new CCDrawNode(); draw.BlendFunc = CCBlendFunc.NonPremultiplied; AddChild(draw, 10); }
/// <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); } } }
public TMXIsoObjectsTest() : base("TileMaps/iso-test-objectgroup") { var objectGroup = tileMap.ObjectGroupNamed("Object Group 1"); var objects = objectGroup.Objects; var drawNode = new CCDrawNode(); foreach (var dict in objects) { float x = float.Parse(dict["x"]); float y = float.Parse(dict["y"]); float width = (dict.ContainsKey("width") ? float.Parse(dict["width"]) : 0f); float height = (dict.ContainsKey("height") ? float.Parse(dict["height"]) : 0f); var color = new CCColor4B(255, 255, 255, 255); drawNode.DrawRect(new CCRect(x, y, width, height), CCColor4B.Transparent, 1, color); } tileLayersContainer.AddChild(drawNode, 10); }
public TMXHexTest() : base("TileMaps/hexa-test1") { CCLayerColor color = new CCLayerColor(new CCColor4B(64, 64, 64, 255)); AddChild(color, -1); drawNode = new CCDrawNode(); tileLayersContainer.AddChild(drawNode); var touchListener = new CCEventListenerTouchOneByOne(); touchListener.OnTouchBegan = OnTouchBegan; AddEventListener(touchListener); }
public void DrawEllipse(Dictionary<string, string> dict, CCDrawNode draw) { float x = float.Parse( dict["x"] ); float y = float.Parse( dict["y"] ); float width = float.Parse( dict["width"] ); float height = float.Parse( dict["height"] ); draw.DrawEllipse (new CCRect (x, y, width, height), 1, new CCColor4B (0, 0, 255, 255)); }
public void DrawPolyline(Dictionary<string, string> dict, CCDrawNode draw) { List<CCPoint> points = ParsePoints(dict["points"]); var color = new CCColor4B( 255, 0, 255 ); for ( int i = 0; i < points.Count-1; i++ ) { draw.AddLineVertex(new CCV3F_C4B(points[i], color)); draw.AddLineVertex(new CCV3F_C4B(points[i+1], color)); } }
public override void Draw(CocosSharp.CCDrawNode node) { node.DrawRect(Bounds(), CCColor4B.Transparent, LINE_THICKNESS, CCColor4B.Green); }