Skip to content

Instantly share code, notes, and snippets.

@akarsh1995
Last active July 10, 2021 11:06
Show Gist options
  • Select an option

  • Save akarsh1995/248448a73a76ef05f4176224f3746150 to your computer and use it in GitHub Desktop.

Select an option

Save akarsh1995/248448a73a76ef05f4176224f3746150 to your computer and use it in GitHub Desktop.
mxjs
window.gameManager = {
onGameInit: function () {
return {
userId: "1",
gameId: "2",
roomId: "3",
highestScore: 90,
lastLevel: 0, // user's current level
gameMode: "score", // "score" or "win"
isFirstOpen: true, // true or false
roomType: "free_room" // "free_room" or "priced_room"
}
},
onGameStart: function() { console.log("onGameStart is called")},
getGameSettings: function() { console.log("getGameSettings is called")},
onTrack: function() {},
onError: function() {},
onCheckRewardedVideoAds: function() { console.log("onCheckRewardedVideoAds is called")},
onShowRewardedVideoAds: function() { console.log("onShowRewardedVideoAds is called")},
onGameOver: function() {}
}
// read from local storage
try {
if (typeof gameManager !== 'undefined') {
const gameConfigString = gameManager.onGameInit()
const config = JSON.parse(gameConfigString)
console.log(config)
}
} catch (e) {
console.log("Error Parsing Config")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment