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); }
internal override void Clear() { Squadrons = null; Aircrafts = null; PlayerAircrafts = null; DownedAircrafts = null; ActiveAircrafts = null; ActiveSquadrons = null; Projectiles = null; DrawNodeUsers = null; GUILayer = null; TouchCountSource = null; this.ActiveChunks = null; this.FirstTouchListener = null; this.HighDrawNode = null; this.KnownChunks = null; this.LowDrawNode = null; if (Scroller != null) { this.Scroller.MoveFunction = null; } this.Scroller = null; this.StopAllActions(); this.ResetCleanState(); }
protected override void AddedToScene() { base.AddedToScene(); // Use the bounds to layout the positioning of our drawable assets var bounds = VisibleBoundsWorldspace; // position the label on the center of the screen label.Position = bounds.Center; step = (int)VisibleBoundsWorldspace.MaxX / SIZE; for (int i = 0; i < 5; i++) { var rectsquad = new RectSquad(5, 2, UnitType.SwordsMan, Team.Blue, 15 * i + 10, 15 * i + 10); var isAdded = army.AddSquad(rectsquad); if (isAdded) { var a = new CCRect(rectsquad.MinX * step, rectsquad.MinY * step, (rectsquad.MaxX - rectsquad.MinX) * step, (rectsquad.MaxY - rectsquad.MinY) * step); var drowNode = new CCDrawNode(); drowNode.DrawRect(a, CCColor4B.Green); AddChild(drowNode); lists.Add(new Tuple <CCDrawNode, ISquad>(drowNode, rectsquad)); } } // Register for touch events var touchListener = new CCEventListenerTouchAllAtOnce(); touchListener.OnTouchesEnded = OnTouchesEnded; AddEventListener(touchListener, this); }
public YesNoDialog(string title, string content, Action <object> yes, Action <object> no) { _title = new MenuItemNoActionLable(new CCLabel(title, "arial", 40)) { //Position=new CCPoint(GlobalGameData.Window_Center_X,GlobalGameData.Window_Center_Y+50), Color = CCColor3B.White, }; _content = new MenuItemNoActionLable(new CCLabel(content, "arial", 20)) { //Position=new CCPoint(GlobalGameData.Window_Center_X,GlobalGameData.Window_Center_Y), Color = CCColor3B.White, }; _yes = new CCMenuItemLabel(new CCLabel("はい", "arial", 50) { // Position = new CCPoint(GlobalGameData.Window_Center_X, GlobalGameData.Window_Center_Y) }, yes); _no = new CCMenuItemLabel(new CCLabel("いいえ", "arial", 50) { //Position = new CCPoint(GlobalGameData.Window_Center_X, GlobalGameData.Window_Center_Y) }, no); int margin = 10; var drawNode_height = _title.ContentSize.Height + _content.ContentSize.Height + _yes.ContentSize.Height + 3 * margin; var drawNode_width = 2 * margin + _content.ContentSize.Width; var _drawNode = new CCDrawNode(); _drawNode.DrawRect(new CCRect(GlobalGameData.Window_Center_X, GlobalGameData.Window_Center_Y, drawNode_width, drawNode_height), CCColor4B.White); // _backGround = _drawNode; }
private void InitDraw() { //this last... ALWAYS! drawNode = new CCDrawNode(); this.AddChild(drawNode); this.CreateGraphic(); }
protected override CCDrawNode Draw() { var node = new CCDrawNode(); var color = GameColors.WallsColor4B; var basisX = this.Position == WallPosition.Left ? 0 : 6; var vertexX = this.Position == WallPosition.Left ? 6 : 0; var numberOfTriangles = this.Height / 12; var triangles = new List <CCV3F_C4B>(); for (int i = 0; i < numberOfTriangles; i++) { var y = i * 12; triangles.AddRange(new [] { new CCV3F_C4B(new CCPoint(basisX, y), color), new CCV3F_C4B(new CCPoint(vertexX, y + 12 / 2), color), new CCV3F_C4B(new CCPoint(basisX, y + 12), color), }); } node.DrawTriangleList(triangles.ToArray()); node.PositionX = this.Position == WallPosition.Left ? 20 : ScreenRight - 26; return(node); }
/// <summary> /// Returns a CCDrawNode that draws the polygon /// </summary> /// <returns></returns> internal CCDrawNode CreateDrawNode(CCColor4B fillColor, float borderWidth, CCColor4B borderColor, bool closePolygon = true) { var drawNode = new CCDrawNode(); drawNode.DrawPolygon(Points, Points.Length, fillColor, borderWidth, borderColor, closePolygon); return(drawNode); }
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; var originNode = new CCDrawNode(); originNode.DrawDot(origin, 10, new CCColor4F(CCColor4B.Magenta)); AddChild(originNode); PositionMonkey(); rotateAround = new CCRotateAroundTo(2.0f, origin, 45, -1); // Register for touch events var touchListener = new CCEventListenerTouchAllAtOnce(); touchListener.OnTouchesEnded = OnTouchesEnded; AddEventListener(touchListener, this); }
public TMXIsoObjectsTest() { CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/iso-test-objectgroup"); AddChild(map, -1, kTagTileMap); CCSize s = map.ContentSize; CCLog.Log("ContentSize: {0}, {1}", s.Width, s.Height); var objectGroup = map.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); } map.AddChild(drawNode, 10); }
public MainLayer() : base(CCColor4B.AliceBlue) { _canvasNode = new CCDrawNode(); _recognizerCanvasNode = new CCDrawNode(); _lineRecognizer = new LineRecognizer(); _shapeNode = new CCDrawNode(); AddChild(_shapeNode); AddChild(_canvasNode); AddChild(_recognizerCanvasNode); if (_drawDebug) { _lineRecognizer.LineFound = (line) => _recognizerCanvasNode.DrawLine(line.P1.ToCCPoint(), line.P2.ToCCPoint(), 5, CCColor4B.Blue); } // Register patterns (concept) _patternEvaluator = new PatternEvaluator(); _patternEvaluator.Add("button").When(Pattern.WideRectangle); _patternEvaluator.Add("image").When(Pattern.Cross); _patternEvaluator.Add("text").When(p => p.Repetitive(ip => ip.MovesRight().MovesLeftAndDown()).MovesRight()); _patternEvaluator.Add("entry").When(p => p.MovesDown().MovesRight().MovesUp().Bounds(BoundsDescriptor.IsWide)); _patternEvaluator.Add("lineoftext").When(p => p.MovesRight()); _patternEvaluator.Add("delete").When(p => p.MovesRightAndUp()); }
public Button(CCPoint position, CCSize dimensions) : base() { this.Position = position; this.Dimensions = dimensions; this.ContentSize = this.Dimensions; this.FillColor = CCColor4B.White; this.BorderWidth = 2; this.BorderColor = CCColor4B.Black; this.Text = ""; this.TextColor = CCColor3B.Black; this.FontSize = 5; this.drawNode = new CCDrawNode(); this.AddChild(this.drawNode); this.textLabel = new CCLabel("hello", "Arial", this.FontSize, CCTextAlignment.Center); this.textLabel.PositionX = this.Dimensions.Width * 0.5f; this.textLabel.PositionY = this.Dimensions.Height * 0.5f; this.textLabel.Color = CCColor3B.Black; this.AddChild(this.textLabel); }
public void Init(CCPoint point, CCDrawNode drawNode) { height = 50; var midheight = height / 2; width = 100; var midwidth = width / 2; rectangle = new CCRect(point.X - midwidth, point.Y - midheight, width, height); drawNode.DrawRect(rectangle, colour.To4B()); labelNode = new CCLabel(label, "fonts/MarkerFelt", 22, CCLabelFormat.SpriteFont) { Position = point }; AddChild(labelNode, 3); ClickEventListener.OnMouseUp = (ccevent) => { if (!rectangle.IsClickOnMe(ccevent)) { return; } ButtonActive = true; if (OnClick != null) { OnClick.Invoke(ccevent); } drawNode.RedrawMe(); }; }
private void CreateMusicVolumeControls() { const float x = 100; float y = this.ContentSize.Height - 120; musicVolumeUp = new CCDrawNode(); MakeUpArrowGraphic(musicVolumeUp); musicVolumeUp.PositionX = x; musicVolumeUp.PositionY = y; this.AddChild(musicVolumeUp); y -= 30; musicVolumeLabel = new CCLabel("", "Arial", 24, CCLabelFormat.SystemFont); musicVolumeLabel.HorizontalAlignment = CCTextAlignment.Center; musicVolumeLabel.PositionX = x; musicVolumeLabel.PositionY = y; UpdateMusicVolumeDisplay(); this.AddChild(musicVolumeLabel); y -= 60; musicVolumeDown = new CCDrawNode(); MakeDownArrowGraphic(musicVolumeDown); musicVolumeDown.PositionX = x; musicVolumeDown.PositionY = y; this.AddChild(musicVolumeDown); }
public EmbarkLayer() : base(CCColor4B.Gray) { // Nodes label = new CCLabel("Option 1", "fonts/MarkerFelt", 22, CCLabelFormat.SpriteFont); drawNode = new CCDrawNode(); AddChild(label); AddChild(drawNode); mouseLabel = new CCLabel($"X: 0 Y: 0", "fonts/MarkerFelt", 22, CCLabelFormat.SpriteFont); AddChild(mouseLabel); yesNo = new YesNoControl(); drawNode.AddChild(yesNo); startButton = new UIButton(new CCSprite("UI/start")) { SpriteAnchorPoint = CCPoint.AnchorMiddle, Position = new CCPoint(VisibleBoundsWorldspace.MidX, 200) }; startButton.OnClick = Start; AddChild(startButton); //Events var moveListener = new CCEventListenerMouse(); moveListener.OnMouseMove = (ev) => { mouseLabel.Text = $"X: {ev.CursorX} Y: {VisibleBoundsWorldspace.MaxY - ev.CursorY}"; mouseLabel.Position = new CCPoint(ev.CursorX, VisibleBoundsWorldspace.MaxY - ev.CursorY); }; AddEventListener(moveListener); }
public DrawNodeTest1() { draw = new CCDrawNode(); draw.BlendFunc = CCBlendFunc.NonPremultiplied; AddChild(draw, 10); }
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); }
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 override void OnEnter() { base.OnEnter(); var windowSize = Layer.VisibleBoundsWorldspace.Size; CCRenderTexture text = new CCRenderTexture(windowSize, windowSize); AddChild(text, 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(); }
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); }
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); }
private void CreateDrawNode(float width, float height) { drawNode = new CCDrawNode(); this.AddChild(drawNode); backgroundRect = new CCRect(0, 0, width, height); DrawGraphic(CCPoint.Zero); this.ContentSize = drawNode.ScaledContentSize; }
protected override CCDrawNode Draw() { var node = new CCDrawNode(); node.DrawRect(new CCRect(0, 0, 20, this.Height), GameColors.BackgroundColor4B); node.PositionX = this.Position == WallPosition.Left ? 0 : ScreenRight - 20; return(node); }
private void MakeBox(int xpos, int ypos, int width, int height, int thickness)//Method for creating boxes { var drawNode = new CCDrawNode(); var rect = new CCRect(xpos, ypos, width, height); drawNode.DrawRect(rect, fillColor: CCColor4B.Transparent, borderWidth: thickness, borderColor: CCColor4B.White); AddChild(drawNode); }
public Combatant(TeamColor teamColor, string unitStats) : base(teamColor) { State = ActionState.walking; timeUntilAttack = 0; targetLine = new CCDrawNode(); InitFromJSON(unitStats); }
public Base(TeamColor teamColor) : base(teamColor) { maxHealth = 1000; currentHealth = maxHealth; drawNode = new CCDrawNode(); this.AddChild(drawNode); CreateCastleSprite(); CreateGraphic(); }
public GameButton(int positionX, int positionY, int sizeX, int sizeY, string text) { button = new CCDrawNode(); button.AnchorPoint = CCPoint.AnchorUpperLeft; button.PositionX = positionX; button.PositionY = positionY; }
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)); }
/********************************************************************** *********************************************************************/ //draw everything. Begginging from the Bottom void DrawLabelsAndBoxes() { ///////draw 29 lines of boxes and labels float yPos = 15; for (int i = 0; i < 29; i++) { //draw label on the left side var ccl_LeftNumber = new CCLabel((28 - i).ToString(), "Arial", 20); ccl_LeftNumber.Position = new CCPoint(20, yPos + 25); ccl_LeftNumber.Color = CCColor3B.Black; layer.AddChild(ccl_LeftNumber); //draw the box on the left side var leftBox = new CCRect(40, yPos, 40, 50); //x,y,length, width CCDrawNode cc_leftBox = new CCDrawNode(); cc_leftBox.DrawRect( leftBox, fillColor: CCColor4B.White, borderWidth: 1, borderColor: CCColor4B.Gray); layer.AddChild(cc_leftBox); //draw label on the right side var ccl_RightNumber = new CCLabel((28 - i).ToString(), "Arial", 20); ccl_RightNumber.Position = new CCPoint(380, yPos + 25); ccl_RightNumber.Color = CCColor3B.Black; layer.AddChild(ccl_RightNumber); //draw the box on the right side var rightBox = new CCRect(320, yPos, 40, 50); CCDrawNode cc_rightBox = new CCDrawNode(); cc_rightBox.DrawRect( rightBox, fillColor: CCColor4B.White, borderWidth: 1, borderColor: CCColor4B.Gray); layer.AddChild(cc_rightBox); //set yPos yPos += 65; //50 heigth + 15 distance } ///////////draw labels on the top //draw label on the left side var ccl_LNumber = new CCLabel("sender", "Arial", 20); ccl_LNumber.Position = new CCPoint(55, yPos + 25); ccl_LNumber.Color = CCColor3B.Gray; layer.AddChild(ccl_LNumber); //draw label on the right side var ccl_RNumber = new CCLabel("receiver", "Arial", 20); ccl_RNumber.Position = new CCPoint(345, yPos + 25); ccl_RNumber.Color = CCColor3B.Gray; layer.AddChild(ccl_RNumber); }
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 StartDebugging() { var debugNode = new CCDrawNode(); AddChild(debugNode, 1000); debugDraw = new Box2DDebug(debugNode, PTM_RATIO); debugDraw.Flags = b2DrawFlags.e_shapeBit | b2DrawFlags.e_aabbBit | b2DrawFlags.e_centerOfMassBit | b2DrawFlags.e_jointBit; world.SetDebugDraw(debugDraw); }
public SneakyButtonControl(CCRect rect, int id, CCDrawNode drawNode ) { this.drawNode = drawNode; status = true; //defaults to enabled value = false; active = false; isHoldable = true; isToggleable = false; radius = 32.0f; rateLimit = 1.0f / 120.0f; Position = rect.Origin; ID = id; buttonEvent = new CCEventCustom(SneakyPanelControl.BUTTON_LISTENER_ID); }
public SneakyJoystickControlSkinnedBase(CCRect size, CCDrawNode drawNode) : base(size, drawNode) { BackgroundSprite = new CCSprite(DEFAULT_IMAGE_BACKGROUND); //new ColoredCircleSprite( CCColor4B.Red, 100f); ThumbSprite = new CCSprite(DEFAULT_IMAGE_THUMB); //new ColoredCircleSprite(CCColor4B.Blue,30f); }
public SneakyPanelControl(CCSize visibleBoundsSize, int buttons) : base(visibleBoundsSize) { drawNode = new CCDrawNode(); Buttons = new List<SneakyButtonControlSkinnedBase>(buttons); ContentSize = visibleBoundsSize; }
public SneakyJoystickControl(CCRect rect, CCDrawNode drawNode) : base() { this.drawNode = drawNode; Degrees = 0.0f; Velocity = CCPoint.Zero; AutoCenter = true; HasDeadzone = false; NumberOfDirections = 4; isDPad = false; joystickRadius = rect.Size.Width / 2; ThumbRadius = 32.0f; DeadRadius = 0.0f; AnchorPoint = CCPoint.AnchorMiddle; ControlSize = rect; }
public SneakyJoystickControlSkinnedBase(CCDrawNode drawNode) : this(new CCRect(0, 0, 128, 128), drawNode) { }