internal void UpdateDrawNode() { var bounds = VisibleBoundsWorldspace; const float LINE_WIDTH = 20f; const float BAR_WIDTH = 40f; const float BAR_BOX_HEIGHT = BAR_WIDTH + LINE_WIDTH * 2; float barBoxWidth = bounds.Size.Width - MULTIPL_BOX_SIZE.Width; DrawNode.Clear(); // draw the combo bar box and the multiplier box DrawNode.DrawRect(new CCRect(0, 0, barBoxWidth, BAR_BOX_HEIGHT), CCColor4B.White); DrawNode.DrawRect(new CCRect(barBoxWidth, 0, MULTIPL_BOX_SIZE.Width, MULTIPL_BOX_SIZE.Height), CCColor4B.White); DrawNode.DrawRect(new CCRect(barBoxWidth + LINE_WIDTH, LINE_WIDTH, MULTIPL_BOX_SIZE.Width - 2 * LINE_WIDTH, MULTIPL_BOX_SIZE.Height - 2 * LINE_WIDTH), CCColor4B.Black); // draw the combo bar CCRect barFull = new CCRect(LINE_WIDTH, LINE_WIDTH, barBoxWidth - 2 * LINE_WIDTH, BAR_WIDTH); CCRect bar = new CCRect(LINE_WIDTH, LINE_WIDTH, barFull.Size.Width * MultiplProgressVisible, BAR_WIDTH); // choose the color var barColor = MultiplierBarColor(Multiplier); var barColorBehind = MultiplierBarColor(Multiplier - 1); DrawNode.DrawRect(barFull, barColorBehind); DrawNode.DrawRect(bar, barColor); //DrawNode.DrawPolygon(new CCPoint[] { CCPoint.Zero, new CCPoint(barBoxWidth, 0), new CCPoint(barBoxWidth, 0), new CCPoint(barBoxWidth, BAR_BOX_HEIGHT), new CCPoint(0, BAR_BOX_HEIGHT) }, 4, CCColor4B.Transparent, LINE_WIDTH, CCColor4B.White); // bar box //DrawNode.DrawPolygon(new CCPoint[] { new CCPoint(barBoxWidth, 0), new CCPoint(bounds.Size.Width, 0), new CCPoint(bounds.Size.Width, MULTIPL_BOX_SIZE.Height), new CCPoint(barBoxWidth, MULTIPL_BOX_SIZE.Height) }, 4, CCColor4B.Transparent, LINE_WIDTH, CCColor4B.White); // multiplier box }
internal void SetSize(CCSize size) { ContentSize = size; DrawNode.Clear(); DrawNode.DrawRect(new CCRect(0, 0, size.Width, size.Height), CCColor4B.White); DrawNode.DrawRect(new CCRect(BORDER, BORDER, size.Width - 2 * BORDER, size.Height - 2 * BORDER), CCColor4B.Black); var mathSize = new CCSize(size.Width - 12 * BORDER, size.Height - 12 * BORDER); MathSprite.FitToBox(mathSize); MathSprite.Position = (CCPoint)ContentSize / 2; }
public void DrawRect(CCPoint position, float width, float height, CCColor4B fillColor, float borderThickness, CCColor4B borderColor) { DrawNode.DrawRect(new CCRect(position.X - width / 2, position.Y - height / 2, width, height), fillColor, borderThickness, borderColor); }