Example #1
0
        protected override void Setup()
        {
            base.Setup();

            if (Instance == null)
            {
                Instance = this;
            }

            this.KeyPress += PongPaddleView_KeyPress;
            int shapeSize       = Math.Min(this.Width, this.Height);
            int shapeSizeThird  = shapeSize / 3;
            int strokeWidth     = 10;
            int strokeWidthHalf = strokeWidth / 2;

            // setup details on paint used for arc
            _paintArc.SetStyle(Paint.Style.Stroke);
            _paintArc.StrokeWidth = strokeWidth;
            // setup details on paint used for rect
            _paintRect.SetStyle(Paint.Style.Fill);
            // setup details on paint used for rect
            _paintDebug.SetStyle(Paint.Style.Stroke);


            Path pathArc = new Path();

            // add the arc slightly smaller then the drawable size will be to prevent clipping
            pathArc.AddArc(0, 0, shapeSize - strokeWidthHalf, shapeSize - strokeWidthHalf, 75, 30);
            _drawableArc.Shape = new PathShape(pathArc, shapeSize, shapeSize);
            _drawableArc.Paint.Set(_paintArc);

            // set collision bounds
            pathArc.ComputeBounds(CollisionBounds, true);
            CollisionBounds.Inset(-strokeWidthHalf, -strokeWidthHalf);

            RectF arcBounds = new RectF();

            pathArc.ComputeBounds(arcBounds, true);
            arcBounds.Top    -= strokeWidthHalf;
            arcBounds.Bottom -= strokeWidthHalf;

            Path pathRect = new Path();

            pathRect.AddRect(arcBounds, Path.Direction.Cw);
            _drawableRect.Shape = new PathShape(pathRect, shapeSize, shapeSize);
            _drawableRect.Paint.Set(_paintRect);

            // setup debug drawable
            pathArc.ComputeBounds(arcBounds, true);
            arcBounds.Inset(-strokeWidthHalf, -strokeWidthHalf);
            arcBounds.Bottom -= strokeWidthHalf;
            Path pathDebug = new Path();

            pathDebug.AddRect(arcBounds, Path.Direction.Cw);
            _drawableDebug.Shape = new PathShape(pathDebug, shapeSize, shapeSize);
            _drawableDebug.Paint.Set(_paintDebug);
        }