Version: stable
crazygames.gameplay_start()
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.)
PARAMETERS
None
crazygames.gameplay_stop()
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
PARAMETERS
None
crazygames.loading_start()
The loadingStart() function has to be called whenever you start loading your game.
PARAMETERS
None
crazygames.loading_stop()
The loadingStop() function has to be called when the loading is complete and eventually the gameplay starts.
PARAMETERS
None
crazygames.show_rewarded_ad(callback)
Show a rewarded ad.
PARAMETERS
callback |
function |
crazygames.show_midgame_ad(callback)
Show a midgame ad.
PARAMETERS
callback |
function |
crazygames.is_ad_blocked(callback)
Detect if the user has an adblocker.
PARAMETERS
callback |
function |
crazygames.request_banner(div,width,height)
Request a banner. The container will be resized to the specified width.
PARAMETERS
div |
string |
|
width |
number |
|
height |
number |
crazygames.request_responsive_banner(div)
The responsive banners feature will request ads that fit into your container, without the need to specify or select a size beforehand.
PARAMETERS
div |
string |
crazygames.clear_banner(div)
Clear a banner. Will also hide it.
PARAMETERS
div |
string |
crazygames.clear_all_banners()
Clear all banners.
PARAMETERS
None
crazygames.invite_link(params)
Create a link to your game to invite others to join a multiplayer game.
PARAMETERS
params |
table |
RETURNS
string |
crazygames.show_invite_button(params)
Display a button in the game footer, that opens a popup containing an invite link.
PARAMETERS
params |
table |
RETURNS
string |
crazygames.hide_invite_button()
Hide the invite button when it is no longer necessary.
PARAMETERS
None
crazygames.get_invite_param(key)
Get an invite link parameters.
PARAMETERS
key |
string |
RETURNS
string |
crazygames.clear_data()
Remove all data items from the local storage.
PARAMETERS
None
crazygames.get_item(key)
Get a data item from the local storage.
PARAMETERS
key |
string |
RETURNS
string |
crazygames.remove_item(key)
Remove a data item from the local storage.
PARAMETERS
key |
string |
crazygames.set_item(key,value)
Add a data item to the local storage.
PARAMETERS
key |
string |
|
value |
string |
crazygames.is_user_account_available()
Before using any user account features, you should always ensure that the user account system is available.
PARAMETERS
None
RETURNS
boolean |
crazygames.get_user(callback)
Retrieve the user currently logged in CrazyGames. If the user is not logged in CrazyGames, the returned user will be null. Will call the provided callback with the logged in user account.
PARAMETERS
callback |
function |
The function takes two arguments, self and the user table |
crazygames.get_user_token(callback)
The user token is in JWT format and contains the userId of the player that is currently logged in to CrazyGames, as well as other useful information. You should send it to your server when required, and verify/decode it there to extract the userId. Will call the provided callback with the token.
PARAMETERS
callback |
function |
The function takes two arguments, self and the token |
crazygames.get_xsolla_user_token(callback)
Generates a custom Xsolla token that you use with the Xsolla SDK. Will call the provided callback with the token.
PARAMETERS
callback |
function |
The function takes two arguments, self and the xsolla token |
crazygames.show_auth_prompt(callback)
By calling this method, the log in or register popup will be displayed on CrazyGames. The user can log in their existing account, or create a new account. Will call the provided callback on log in.
PARAMETERS
callback |
function |
The function takes two arguments, self and the user table |
crazygames.set_auth_listener(callback)
You can register a user auth listener that is triggered when the player logs in to CrazyGames. A log out doesn't trigger the auth listener, since the entire page is refreshed when the player logs out.
PARAMETERS
callback |
function |
The function takes two arguments, self and the user table |
crazygames.remove_auth_listener()
Remove any previously set auth listener.
PARAMETERS
None
crazygames.show_account_link_prompt()
Show an account linking prompt to link a CrazyGames account to the in-game account.
PARAMETERS
None