Game
The Game
module contains various functionality related to the game. It can be accessed like this:
Info
For a demo, please consult the CrazySDK/Demo/GameModule
scene. You can run it directly in the Unity editor.
Instant join
The game module contains the IsInstantJoin
flag, that can be accessed like this:
For multiplayer games, if IsInstantJoin
is true, you should instantly create a new room/lobby for the user. Read more about this on multiplayer requirements page.
Gameplay
We provide functions that enable us to track when and how users are playing your games. These can be used to ensure our site does not perform resource intensive actions while a user is playing.
The GameplayStart
function has to be called whenever the player starts playing or resumes playing after a break (menu/loading/achievement screen, game paused, etc.).
The GameplayStop
function has to be called on every game break (entering a menu, switching level, pausing the game, ...) don't forget to call GameplayStart
when the gameplay resumes.
// Main menu, user clicks start
CrazySDK.Game.GameplayStart();
// Level is over, displaying switching level screen
CrazySDK.Game.GameplayStop();
// Next level starts
CrazySDK.Game.GameplayStart();
// The player is pausing the game by looking into the menu
CrazySDK.Game.GameplayStop();
// The player closes the menu and gets back to the game
CrazySDK.Game.GameplayStart();
Happy time
The HappyTime()
method can be called on various player achievements (beating a boss, reaching a highscore, etc.). It makes the website celebrate (for example by launching some confetti). There is no need to call this when a level is completed, or an item is obtained.
Info
Use this feature sparingly, the celebration should remain a special moment.
Invite Link
This feature lets you share the CrazyGames version of your game to the players and invite them to join a multiplayer game. You can call inviteLink
with a map of parameters that correspond to your game or game room.
var parameters = new Dictionary<string, string>();
parameters.Add("roomId", "1234");
var inviteLink = CrazySDK.Game.InviteLink(parameters);
We provide a helper if you want to automatically copy the invite link to the clipboard.
You can retrieve parameters passed through the invite link with GetInviteLinkParameter
.
Invite button
This feature allows you to display a button in the game footer, that opens a popup containing the invite link. The returned link is similar to the link returned from Invite link.
The invite button should only be used to invite players to a multiplayer gaming session. Please avoid using it for other use cases, such as a "Share" button for example, as this may lead to delayed submission check or even game rejection.
You can show the invite button like this:
var parameters = new Dictionary<string, string>();
parameters.Add("roomId", "1234");
// the returned link looks the same as the link returned by the InviteLink method
var inviteLink = CrazySDK.Game.ShowInviteButton(parameters);
Don't forget to hide the invite button when it is no longer necessary: