Example #1
0
        public override void ViewWillLayoutSubviews()
        {
            base.ViewWillLayoutSubviews();

            NSError error = new NSError();
            string  backgroundMusicURL = NSBundle.MainBundle.PathForResource("background-music-aac", "caf");

            background_music_player               = AVAudioPlayer.FromUrl(new NSUrl(backgroundMusicURL), out error);
            background_music_player.Volume        = 0.2f;
            background_music_player.NumberOfLoops = -1;
            background_music_player.PrepareToPlay();
            background_music_player.Play();

            // Configure the view.
            var skView = (SKView)View;

            // Create and configure the scene.
            var scene = new MyScene(skView.Bounds.Size);

            scene.ScaleMode = SKSceneScaleMode.AspectFill;

            new UIAlertView("How to play!", "Use swipe gestures to play:\n→ Turn rigth\n← Turn left\n↑ Go up\n↓ Go down\n Easy, right? ;) Enjoy it!", null, "Let's Play!!", null).Show();

            // Present the scene
            skView.PresentScene(scene);
        }
        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);
                }),
            }));
        }