Example #1
0
        public override void DidMoveToView(SKView view)
        {
            // Setup your scene here
            var myLabel = SKLabelNode.FromFont("Trebuchet MS");

            myLabel.Text     = "Starting..";
            myLabel.FontSize = 44;
            myLabel.Position = new CGPoint(Frame.GetMidX(), Frame.GetMidY());

            AddChild(myLabel);
        }
Example #2
0
        public override void DidMoveToView(SKView view)
        {
            // Setup your scene here
            var myLabel = SKLabelNode.FromFont("Chalkduster");

            myLabel.Text     = "Hello, World!";
            myLabel.FontSize = 65;
            myLabel.Position = new CGPoint(Frame.GetMidX(), Frame.GetMidY());

            AddChild(myLabel);
        }
Example #3
0
        public override void DidMoveToView(SKView view)
        {
                        #if TARGET_OS_MAC
            var fontName = NSFont.SystemFontOfSize(65).FontName;
            var label    = SKLabelNode.FromFont(fontName);
            label.Text     = SceneName;
            label.FontSize = 65;
            label.HorizontalAlignmentMode = SKLabelHorizontalAlignmentMode.Left;
            label.VerticalAlignmentMode   = SKLabelVerticalAlignmentMode.Top;
            label.Position = new CGPoint(Frame.GetMinX() + 10, Frame.GetMaxY() - 46);
            AddChild(label);
                        #endif

            AgentSystem            = new GKComponentSystem <GKAgent2D> ();
            TrackingAgent          = new GKAgent2D();
            TrackingAgent.Position = new Vector2((float)Frame.GetMidX(), (float)Frame.GetMidY());
        }
        public void ShowLabel(string label)
        {
            if (Label == null)
            {
                Label = SKLabelNode.FromFont("Myriad Set");
                if (Label == null)
                {
                    Label = SKLabelNode.FromFont("Avenir-Heavy");
                }
                Label.FontSize = 140;
                Label.Position = new CGPoint(0, 0);

                AddChild(Label);
            }
            else
            {
                if (label != null)
                {
                    Label.Position = new CGPoint(0, Size.Height * 0.25f);
                }
            }

            if (label == null)
            {
                Label.RunAction(SKAction.FadeOutWithDuration(0.5));
            }
            else
            {
                                #if __IOS__
                if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
                {
                    Label.FontSize = label.Length > 10 ? 50 : 80;
                }
                else
                                #endif
                Label.FontSize = label.Length > 10 ? 100 : 140;

                Label.Text  = label;
                Label.Alpha = 0.0f;
                Label.RunAction(SKAction.Sequence(new [] {
                    SKAction.WaitForDuration(0.5),
                    SKAction.FadeInWithDuration(0.5)
                }));
            }
        }
        public GameOverScene(SizeF size, int score) : base(size)
        {
            BackgroundColor = new UIColor(0.15f, 0.15f, 0.3f, 1.0f);

            SKLabelNode label = SKLabelNode.FromFont("Chalkduster");

            label.Text      = "Your final score is: " + score + " Points";
            label.FontSize  = 30f;
            label.FontColor = UIColor.Black;
            label.Position  = new PointF(Size.Width / 2, Size.Height / 2);
            AddChild(label);

            RunAction(SKAction.Sequence(new [] {
                SKAction.WaitForDuration(3),
                SKAction.RunBlock(() => {
                    SKTransition reveal = SKTransition.FlipHorizontalWithDuration(0.5);
                    var scene           = new MyScene(size);

                    View.PresentScene(scene, reveal);
                }),
            }));
        }
Example #6
0
        public Button(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 the background
            this.size       = new CGSize(this.label.Frame.Size.Width + 10f, 30f);
            this.background = new SKSpriteNode(SKColor.FromCIColor(new CoreImage.CIColor(0f, 0f, 0f, 0.75f)), size);

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

            // Track mouse event
            base.UserInteractionEnabled = true;
        }
Example #7
0
        public void Setup()
        {
            nfloat w = Bounds.Width;
            nfloat h = Bounds.Height;

            if (w < h)
            {
                nfloat wTmp = w;
                w = h;
                h = wTmp;
            }

            // Setup the game overlays using SpriteKit
            SKScene skScene = SKScene.FromSize(new CGSize(w, h));

            skScene.ScaleMode = SKSceneScaleMode.ResizeFill;

            overlayGroup = SKNode.Create();
            skScene.AddChild(overlayGroup);
            overlayGroup.Position = new CGPoint(0f, h);

            // The Max icon
            SKSpriteNode sprite = SKSpriteNode.FromImageNamed("Images/MaxIcon.png");

            sprite.Position = new CGPoint(50f, -50f);

            overlayGroup.AddChild(sprite);
            sprite.XScale = sprite.YScale = 0.5f;

            for (int i = 0; i < 3; i++)
            {
                flowers [i]          = SKSpriteNode.FromImageNamed("Images/FlowerEmpty.png");
                flowers [i].Position = new CGPoint(110f + i * 40f, -50f);
                flowers [i].XScale   = flowers [i].YScale = 0.25f;
                overlayGroup.AddChild(flowers[i]);
            }

            // The peal icon and count.
            sprite          = SKSpriteNode.FromImageNamed("Images/ItemsPearl.png");
            sprite.Position = new CGPoint(110f, -100f);
            sprite.XScale   = sprite.YScale = 0.5f;
            overlayGroup.AddChild(sprite);

            pearlLabel          = SKLabelNode.FromFont("Chalkduster");
            pearlLabel.Text     = "x0";
            pearlLabel.Position = new CGPoint(152f, -113f);
            overlayGroup.AddChild(pearlLabel);

            // The D-Pad
            sprite          = SKSpriteNode.FromImageNamed("Images/dpad.png");
            sprite.Position = new CGPoint(100f, 100f);
            sprite.XScale   = sprite.YScale = 0.5f;
            skScene.AddChild(sprite);
            padRect = new CGRect(
                (sprite.Position.Y - DPAD_RADIUS) / w,
                1f - (sprite.Position.Y + DPAD_RADIUS) / h,
                2f * DPAD_RADIUS / w,
                2f * DPAD_RADIUS / h
                );

            // Assign the SpriteKit overlay to the SceneKit view.
            OverlayScene = skScene;

            // Setup the pinch gesture
            defaultFov = PointOfView.Camera.XFov;

            var pinch = new UIPinchGestureRecognizer {
                Delegate             = this,
                CancelsTouchesInView = false
            };

            pinch.AddTarget(() => PinchWithGestureRecognizer(pinch));

            AddGestureRecognizer(pinch);
        }