示例#1
0
        public Slider(int width, int height, string text) : base()
        {
            // create a label
            var fontName = "Optima-ExtraBlack";

            this.label           = SKLabelNode.FromFont(fontName);
            this.label.Text      = text;
            this.label.FontSize  = 18;
            this.label.FontColor = SKColor.White;
            this.label.Position  = new CGPoint(0f, -8f);

            // create background & slider
            this.background             = new SKSpriteNode(SKColor.White, new CGSize(width, 2f));
            this.slider                 = SKShapeNode.FromCircle(height);
            this.slider.FillColor       = SKColor.White;
            this.background.AnchorPoint = new CGPoint(0f, 0.5f);

            this.slider.Position     = new CGPoint(this.label.Frame.Size.Width / 2f + 15f, 0f);
            this.background.Position = new CGPoint(this.label.Frame.Size.Width / 2f + 15f, 0f);

            // add to the root node
            this.AddChild(this.label);
            this.AddChild(this.background);
            this.AddChild(this.slider);

            // track mouse event
            base.UserInteractionEnabled = true;
            this.Value = 0f;
        }
示例#2
0
        public static SKShapeNode MakeSquiggle()
        {
            // new Path
            var shape = SKShapeNode.FromCircle(12.5f);

            return(shape);
        }
示例#3
0
        private SKShapeNode CreateLightAtPosition(CGPoint position)
        {
            var circle = SKShapeNode.FromCircle(CountDownLightRadius);

            circle.Position    = position;
            circle.StrokeColor = UIColor.DarkGray;
            circle.LineWidth   = 3;
            circle.FillColor   = UIColor.Red;

            return(circle);
        }
示例#4
0
        GKObstacle AddObstacle(CGPoint point)
        {
            var circleShape = SKShapeNode.FromCircle(DefaultAgentRadius);

            circleShape.LineWidth   = 2.5f;
            circleShape.FillColor   = SKColor.Gray;
            circleShape.StrokeColor = SKColor.Red;
            circleShape.ZPosition   = 1;
            circleShape.Position    = point;
            AddChild(circleShape);

            var obstacle = new GKCircleObstacle(DefaultAgentRadius);

            obstacle.Position = new Vector2((float)point.X, (float)point.Y);

            return(obstacle);
        }
示例#5
0
        public void InitAgent(SKScene scene, float radius, CGPoint position)
        {
            Position  = position;
            ZPosition = 10f;
            scene.AddChild(this);

            Agent = new GKAgent2D {
                Radius          = radius,
                Position        = new Vector2((float)position.X, (float)position.Y),
                Delegate        = this,
                MaxSpeed        = 100f,
                MaxAcceleration = 50f
            };

            var circleShape = SKShapeNode.FromCircle(radius);

            circleShape.LineWidth = 2.5f;
            circleShape.FillColor = SKColor.Gray;
            circleShape.ZPosition = 1f;
            AddChild(circleShape);

            const float triangleBackSideAngle = (float)((135f / 360f) * (2 * Math.PI));
            var         points = new [] {
                new CGPoint(radius, 0f),                                                                          // Tip
                new CGPoint(radius * Math.Cos(triangleBackSideAngle), radius * Math.Sin(triangleBackSideAngle)),  // Back bottom
                new CGPoint(radius * Math.Cos(triangleBackSideAngle), -radius * Math.Sin(triangleBackSideAngle)), // Back top
                new CGPoint(radius, 0f)                                                                           // Back top
            };

            TriangleShape           = SKShapeNode.FromPoints(ref points [0], (nuint)points.Length);
            TriangleShape.LineWidth = 2.5f;
            TriangleShape.ZPosition = 1f;
            AddChild(TriangleShape);

            Particles            = SKNode.FromFile <SKEmitterNode> ("Trail.sks");
            DefaultParticleRate  = (float)Particles.ParticleBirthRate;
            Particles.Position   = new CGPoint(-radius + 5, 0);
            Particles.TargetNode = scene;
            Particles.ZPosition  = 0f;
            AddChild(Particles);
        }