-
-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit '2db80256856c14f8bc85dbbe453be64f4ac2556d'
- Loading branch information
Showing
391 changed files
with
15,748 additions
and
975 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
cats: | ||
- Dēmētrius ille | ||
- GAKONS | ||
- Penny Gautreaux | ||
|
||
businessCats: | ||
- myOmochi Games | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# ct.gamedistribution | ||
|
||
A module for `Game Distribution` SDK. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
# General use of `ct.gamedistribution` | ||
An easy way to display `Game Distribution` Ads. | ||
|
||
## Catmods' settings -> Game Distribution | ||
|
||
* GameID | ||
* Auto init | ||
* Localization of the Ads | ||
* Enable GDPR | ||
* Enable Debug, note you can enable debug in console just write `gdsdk.openConsole()` then the GD debug bar will appear, and it will keep showing until you delete the localStorage in your game. | ||
|
||
## How do you use `ct.gamedistribution`? | ||
|
||
* To use it you need to init the `Game Distribution SDK`. | ||
|
||
* You can do this from `Catmods' settings -> Game Distribution` and check `Auto init Game Distribution SDK`. | ||
|
||
* If you prefer to initialize `Game Distribution SDK` manually you can add this code into a `custom script`. | ||
|
||
### Init the Game Distribution SDK | ||
|
||
!important: Make sure this runs only `one time`. | ||
|
||
```js | ||
ct.gamedistribution.init(); | ||
``` | ||
|
||
### Show an Ad manually | ||
|
||
Inside a `Click` event add this code: | ||
|
||
```js | ||
if (!ct.gamedistribution.adPlaying) { | ||
ct.gamedistribution.showAd(); | ||
} | ||
``` | ||
|
||
* Now go to your `UI` room and add an event of `Ads` `Check if an Ads has finished` | ||
|
||
* Inside the code and according to your game logic you can add something like this: | ||
|
||
```js | ||
ct.room.coins +=1; | ||
``` | ||
- This way you reward the player with 1 coin after the Ad has finished. | ||
|
||
## Available methods | ||
|
||
`ct.gamedistribution.init();` | ||
Initialize the Game distribution SDK, manually. | ||
|
||
`ct.gamedistribution.gdsdkReady()` | ||
Check if Game distribution SDK, is ready to show Ads. | ||
|
||
`ct.gamedistribution.pauseGame()` | ||
Used to pause the game. | ||
|
||
`ct.gamedistribution.resumeGame()` | ||
Used to resume the game. | ||
|
||
`ct.gamedistribution.showAd();` | ||
Is available when GD SDK is ready, so you can call this method in a button click of wherever you want but `make sure is called one time` | ||
|
||
`ct.gamedistribution.isAdFinished();` | ||
This method is the same as the event that you can add into the events editor in the room, according to the image we seen above. | ||
|
||
## Available Variables | ||
|
||
* var isFinished: boolean; `Used to check if an Ad is completed.` | ||
* var isPaused: boolean; `Used to check if the game is paused or running.` | ||
* var sdkReady: boolean; `Use to check if the Game Distribution SDK is ready to display Ads.` | ||
* var adPlaying: boolean; `Used to check if an Ad is showing.` | ||
|
||
### Game Distribution SDK | ||
|
||
Check if the `Game Distribution SDK` is ready to display Ads. | ||
```js | ||
if (ct.gamedistribution.sdkReady) { | ||
//Usually you don't need to use this method but in case you want. | ||
//Do something here... | ||
} | ||
``` | ||
|
||
### Ad has finished, completed. | ||
|
||
In case you don't want to use the built-in `event` to check if the Ad has finished, you can use `ct.gamedistribution.isFinished` in `OnStep` like: | ||
```js | ||
if(ct.gamedistribution.isFinished){ | ||
//Reward the player here | ||
this.coins +=1; | ||
ct.gamedistribution.isFinished = false; | ||
ct.gamedistribution.isPaused = false; | ||
} | ||
``` | ||
### Pause the game. Please make sure you mute the music and sounds otherwise Game Distribution is going to reject your game. | ||
|
||
In some case you maybe want to pause the game manually do: | ||
```js | ||
if(!ct.gamedistribution.isPaused){ | ||
if (ct.gamedistribution.adPlaying) { | ||
ct.gamedistribution.isPaused = true; | ||
//Do something here... | ||
} | ||
} | ||
``` | ||
|
||
### Resume the game after the Ad is completed. Remember to enable music and sounds. | ||
|
||
In case you need to manually resume the game do: | ||
```js | ||
if(ct.gamedistribution.isPaused){ | ||
if (!ct.gamedistribution.adPlaying) { | ||
ct.gamedistribution.isPaused = false; | ||
//Do something | ||
} | ||
} | ||
``` | ||
|
||
### Show an Ad manually | ||
Make sure this runs `one time` maybe with a `button click` or any event that triggers `only once`. | ||
```js | ||
if (!ct.gamedistribution.adPlaying) { | ||
ct.gamedistribution.showAd(); | ||
} | ||
``` | ||
|
||
|
||
A mini tutorial is available here: https://www.youtube.com/watch?v=CO7kU1vkwXg and thats it... | ||
|
||
Enjoy making money with Ads. | ||
|
||
By Ulises Freitas. |
7 changes: 7 additions & 0 deletions
7
app/data/ct.libs/gamedistribution/events/adfinished_thisOnStep.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
if (ct.gamedistribution.isFinished) { | ||
ct.gamedistribution.isFinished = false; | ||
ct.gamedistribution.isPaused = false; | ||
/*%%USER_CODE%%*/ | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
app/data/ct.libs/gamedistribution/events/pausegame_thisOnStep.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
if(!ct.gamedistribution.isPaused){ | ||
if (ct.gamedistribution.adPlaying) { | ||
ct.gamedistribution.isPaused = true; | ||
/*%%USER_CODE%%*/ | ||
} | ||
} | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
app/data/ct.libs/gamedistribution/events/resumegame_thisOnStep.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
if(ct.gamedistribution.isPaused){ | ||
if (!ct.gamedistribution.adPlaying) { | ||
ct.gamedistribution.isPaused = false; | ||
/*%%USER_CODE%%*/ | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
app/data/ct.libs/gamedistribution/events/sdkready_thisOnCreate.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
if (ct.gamedistribution.sdkReady) { | ||
/*%%USER_CODE%%*/ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
(function ctGamedistribution(ct) { | ||
ct.gamedistribution = { | ||
|
||
init() { | ||
ct.gamedistribution.isFinished = false; | ||
ct.gamedistribution.adPlaying = false; | ||
ct.gamedistribution.isPaused = false; | ||
|
||
window["GD_OPTIONS"] = { | ||
"gameId": "/*%gameID%*/", // Your gameId can be found at your Gamedistribution.com account. | ||
advertisementSettings: { | ||
debug: [/*%debugMode%*/][0], | ||
"locale": "/*%gdsdkLocale%*/", // Locale used in IMA SDK, this will localize the "Skip ad after x seconds" phrases. | ||
}, | ||
"onEvent": function(event) { | ||
switch (event.name) { | ||
case "SDK_GAME_START": | ||
ct.gamedistribution.adPlaying = false; | ||
break; | ||
case "SDK_GAME_PAUSE": | ||
ct.gamedistribution.adPlaying = true; | ||
break; | ||
case "SDK_READY": | ||
ct.gamedistribution.sdkReady = true; | ||
break; | ||
case "SDK_ERROR": | ||
/** This is not managed right now */ | ||
ct.gamedistribution.sdkError = true; | ||
break; | ||
case "COMPLETE": | ||
ct.gamedistribution.isFinished = true; | ||
ct.gamedistribution.adPlaying = false; | ||
break; | ||
case "SDK_GDPR_TRACKING": | ||
/** This is not managed right now */ | ||
ct.gamedistribution.sdkGdprTracking = true; | ||
break; | ||
case "SDK_GDPR_TARGETING": | ||
/** This is not managed right now */ | ||
ct.gamedistribution.sdkGdprTargeting = true; | ||
break; | ||
case "SDK_GDPR_THIRD_PARTY": | ||
/** This is not managed right now */ | ||
ct.gamedistribution.sdkGdprThirdParty = true; | ||
break; | ||
} | ||
}, | ||
}; | ||
(function(d, s, id) { | ||
var js, fjs = d.getElementsByTagName(s)[0]; | ||
if (d.getElementById(id)) return; | ||
js = d.createElement(s); | ||
js.id = id; | ||
js.src = 'https://html5.api.gamedistribution.com/main.min.js'; | ||
fjs.parentNode.insertBefore(js, fjs); | ||
}(document, 'script', 'gamedistribution-jssdk')); | ||
|
||
/** | ||
* Includes a basic GDPR | ||
*/ | ||
if([/*%gdpr%*/][0]){ | ||
const script = document.createElement("script"); | ||
script.src = "//acdn.adnxs.com/cmp/cmp.complete.bundle.js"; | ||
document.head.appendChild(script); | ||
} | ||
|
||
}, | ||
showAd(){ | ||
if (typeof gdsdk !== 'undefined' && gdsdk.showAd !== 'undefined') { | ||
gdsdk.showAd(); | ||
} | ||
}, | ||
pauseGame(){ | ||
if(ct.gamedistribution.adPlaying){ | ||
return true; | ||
} | ||
}, | ||
resumeGame(){ | ||
if(!ct.gamedistribution.adPlaying){ | ||
return true; | ||
} | ||
} | ||
} | ||
/** | ||
* Auto init the Game Distribution SDK. | ||
*/ | ||
if([/*%autoInit%*/][0]){ | ||
ct.gamedistribution.init(); | ||
} | ||
})(ct); |
Oops, something went wrong.