Set Up Core Loop & Gameplay
Overviewβ
Below, we walk your through the core elements of setting up your core loop and gameplay on Skillz. Beginning with starting a match, reporting a score and eventually getting back to the Skillz UI. By the end of this article, you will have a complete core loop allowing you to fully test a standard Skillz match.
Before continuing, make sure you have completed the previous steps - Launch the Skillz UI.
Launching Your Gameplayβ
When Skillz launches, it will take control of the user experience. The player will start a match and Skillz will notify the game. At this point, control is given back to your game to start the match gameplay. The examples below illustrate how to handle starting a match.
- Unity/C#
- Legacy Unity/C#
- iOS/Swift
- iOS/Objective-C
- Android
#import "AppDelegate.h"
#import <Skillz/SkillzInstance.h>
@implementation AppDelegate
- (void)tournamentWillBegin:(NSDictionary *)gameParameters withMatchInfo:(SKZMatchInfo *)matchInfo
{
}
This example has an AppDelegate class that has implemented the SkillzDelegate protocol. The tournamentWillBegin:withMatchInfo: method is called when the player's match is about to begin. Implement this method to navigate to the View/ViewController that represents the gameplay portion of your game.
Additionally, the gameParameters parameter holds key value parameters of the specific type of tournament being played. These parameters are created by your in the Skillz Developer Console when defining the types of tournaments your game will support.
import UIKit
import Skillz
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, SkillzDelegate {
func tournamentWillBegin(_ gameParameters: [AnyHashable : Any]!, with matchInfo: SKZMatchInfo!) {
}
}
This example has an AppDelegate class that has implemented the SkillzDelegate protocol. The tournamentWillBegin method is called when the player's match is about to begin. Implement this method to navigate to the View/ViewController that represents the gameplay portion of your game.
Additionally, the _ gameParameters parameter holds key value parameters of the specific type of tournament being played. These parameters are created by your in the Skillz Developer Console when defining the types of tournaments your game will support.
As described in the example for launching Skillz, Skillz will launch the activity that you set for the skillz_game_activity meta-data tag in your game's AndroidManifest.xml file.
<meta-data android:name="skillz_game_activity" android:value="com.skillz.your.GameActivity" />
When your activity launches, we recommend that you call relevant methods of the Skillz static class to retrieve tournament parameters, and match info. Refer to the API Reference for a list of the methods available.
You should have previously implemented the SkillzMatchDelegate interface but likely only included the stubbed in functions. To handle a match start, you need to expand your implementation of OnMatchWillBegin.
From within OnMatchWillBegin you should:
- Clear any previously stored match settings
- Retrieve the Match object and utilize it to set gameplay parameters
- Load your game scene
// ...
public void OnMatchWillBegin(Match matchInfo) {
SceneManager.LoadScene("GameplayScene");
}
// ...
You should have previously implemented the Skillz Manager. The OnMatchWillBegin extra logic function specified in the SkillzManager can be used to:
- Clear any previously stored match settings
- Retrieve the Match object and utilize it to set gameplay parameters
- Load your game scene, if you have specified a
Game Scenein theSkillz Manager.
// ...
public void OnMatchWillBeginExtraLogic(Match matchInfo) {
//Extra Logic Here
}
// ...