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); }
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); }
void Rect() { var shape = new CCRect( 0, 0, 100, 200); drawNode.DrawRect(shape, fillColor: CCColor4B.Blue, borderWidth: 4, borderColor: CCColor4B.White); }
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 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 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); }
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); }
protected void DrawRectangle(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.DrawRect(new CCRect(x, y, width, height), new CCColor4B(0, 0, 0, 0), 1.0f, new CCColor4B(0, 255, 0)); }
public ActionSkewRotateScale() { box = new CCDrawNode(); box.DrawRect(new CCRect (0.0f, 0.0f, 100.0f, 100.0f), new CCColor4B(255, 255, 0, 255)); box.AnchorPoint = new CCPoint(0, 0); uL = new CCDrawNode(); uL.DrawRect(new CCRect (0.0f, 0.0f, markrside, markrside), new CCColor4B(255, 0, 0, 255)); uL.AnchorPoint = new CCPoint(0, 0); box.AddChild(uL); uR = new CCDrawNode(); uR.DrawRect(new CCRect (0.0f, 0.0f, markrside, markrside), new CCColor4B(0, 0, 255, 255)); uR.AnchorPoint = new CCPoint(0, 0); box.AddChild(uR); AddChild(box); actionTo = new CCSkewTo (2, 0.0f, 2.0f); rotateTo = new CCRotateTo (2, 61.0f); actionScaleTo = new CCScaleTo(2, -0.44f, 0.47f); actionScaleToBack = new CCScaleTo(2, 1.0f, 1.0f); rotateToBack = new CCRotateTo (2, 0); actionToBack = new CCSkewTo (2, 0, 0); }
public ActionRotationalSkewVSStandardSkew() { box1 = new CCDrawNode (); box1.DrawRect(new CCRect (0.0f, 0.0f, 200.0f, 200.0f), new CCColor4B(255, 255, 0, 255)); //new CCLayerColor(); this.AddChild(box1); box1.AnchorPoint = new CCPoint(0.5f, 0.5f); box1.IgnoreAnchorPointForPosition = false; box2 = new CCDrawNode (); box2.DrawRect(new CCRect (0.0f, 0.0f, 200.0f, 200.0f), new CCColor4B(255, 255, 0, 255)); this.AddChild(box2); box2.AnchorPoint = new CCPoint(0.5f, 0.5f); box2.IgnoreAnchorPointForPosition = false; boxLabel1 = new CCLabelTtf("Standard cocos2d Skew", "Marker Felt", 16); this.AddChild(boxLabel1); boxLabel2 = new CCLabelTtf("Rotational Skew", "Marker Felt", 16); this.AddChild(boxLabel2); actionTo = new CCSkewBy(2, 360, 0); actionToBack = new CCSkewBy(2, -360, 0); actionTo2 = new CCRotateBy(2, 360, 0); actionToBack2 = new CCRotateBy(2, -360, 0); }
private void EndGame() { hasGameEnded = true; spawner.IsSpawning = false; paddle.Visible = false; // dim the background: var drawNode = new CCDrawNode(); drawNode.DrawRect( new CCRect (0,0, 2000, 2000), new CCColor4B(0,0,0,160)); hudLayer.Children.Add(drawNode); var endGameLabel = new CCLabel("Game Over\nFinal Score:" + score, "Arial", 40, CCLabelFormat.SystemFont); endGameLabel.HorizontalAlignment = CCTextAlignment.Center; endGameLabel.Color = CCColor3B.White; endGameLabel.VerticalAlignment = CCVerticalTextAlignment.Center; endGameLabel.PositionX = hudLayer.ContentSize.Width / 2.0f; endGameLabel.PositionY = hudLayer.ContentSize.Height / 2.0f; hudLayer.Children.Add(endGameLabel); }
public bool isCollideWithRotatedPaddle(PaddleEntity mPaddle, float angle) { bool collide=false; if (Math.Abs (angle) > 45) { VelocityAngle = -angle / 3; } else { VelocityAngle = -angle/2; } rotatedX = (float)Math.Cos (angle) * (this.PositionX-mPaddle.PositionX) - (float)Math.Sin (angle) * (this.PositionY-mPaddle.PositionY)+mPaddle.PositionX; rotatedY = (float)Math.Sin (angle) * (this.PositionX-mPaddle.PositionX) + (float)Math.Cos (angle) * (this.PositionY-mPaddle.PositionY)+mPaddle.PositionY; rotatedBallRect = new CCRect (rotatedX-this.BoundingWidth/2, rotatedY-this.BoundingHeight/2, this.BoundingWidth, this.BoundingHeight); flatPaddleRect = new CCRect (mPaddle.PositionX-mPaddle.flatBoundingBoxWidth/2, 50f-mPaddle.flatBoundingBoxHeight/2, mPaddle.flatBoundingBoxWidth, mPaddle.flatBoundingBoxHeight); collide = BallPaddleRectIntersects (rotatedBallRect, flatPaddleRect); if (rotatedBallRect.Center.Y < flatPaddleRect.Center.Y) { collide = false; } if (rotatedBallRect.Center.X < (flatPaddleRect.Center.X - mPaddle.flatBoundingBoxWidth / 2)) { collide = false; } if (this.YVelocity > 0) { collide = false; } if (collide) { // Console.WriteLine("X: "+(mPaddle.PositionX-mPaddle.flatBoundingBoxWidth/2).ToString()); // Console.WriteLine("Y: "+(50f-mPaddle.flatBoundingBoxHeight/2).ToString()); // Console.WriteLine("width: "+mPaddle.flatBoundingBoxWidth.ToString()); // Console.WriteLine("height: "+mPaddle.flatBoundingBoxHeight.ToString()); Console.WriteLine("ball: "+rotatedBallRect.MinY.ToString()); Console.WriteLine ("paddle: "+flatPaddleRect.MaxY.ToString ()); Console.WriteLine ("-------------------------------------"); gamelayer.RemoveChild (draw); draw = new CCDrawNode (); draw.DrawRect (rotatedBallRect,new CCColor4B(0,0,0)); draw.DrawRect (flatPaddleRect, new CCColor4B(0,0,0)); gamelayer.AddChild (draw); //Thread.Sleep (1000); } return collide; }
public override void Draw(CocosSharp.CCDrawNode node) { node.DrawRect(Bounds(), CCColor4B.Transparent, LINE_THICKNESS, CCColor4B.Green); }