Xamarin.iOS Spritekit SKScene

DuITAppsDuITApps USMember ✭✭

My design for a simple game consists of few SKScenes (I'm using Xamarin.iOS and SpriteKit with VS 2017 on Mac).

App flow is, it starts with a LaunchScreen and 1st SKScene appears. 1st SKScene has a Play Button and when Tapped, navigates to 2nd SKScene when user can select a Level. 2nd SKScene also has a back button, when Tapped, navigate back to 1st SkScene.

1st SKScene:

    var scene = SKNode.FromFile<GameLevels>("GameLevels");
    scene.parentScene = this;

2nd SKScene:

public override void TouchesBegan(Foundation.NSSet touches, UIKit.UIEvent evt)
            foreach (var touch in touches)
                var location = ((UITouch)touch).LocationInNode(this);

                SKNode skNode = GetNodeAtPoint(location);

                if (skNode.Name == "Prev")

From 2nd SKScene, based on the selected Level, 3rd SKScene is displayed (navigated, using the same technique I have used in the 1st SKScene)

My Question #1:

How do I show a message (for example, when a player collides with an object)?

Btw, I have used the UIAlertController (I did not like the way Message shows up on the screen though)

 UIAlertController alertController = UIAlertController.Create(title, message, UIAlertControllerStyle.Alert);           
 alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Cancel, (obj) => { AlertCancel();}));
 this.View.Window.RootViewController.PresentViewController(alertController, true, null);

My Question #2:

I am attempting to display another SKScene as a message, but before that current SkScene needs to Paused, which I am able to do that using
Scene.View.Paused = true;

But how do I come back to the same state to the GameScene (where actual game is being played and paused and Alert message (another SkScene) is dismissed?

Sign In or Register to comment.