-
Notifications
You must be signed in to change notification settings - Fork 4
Home
Alessandro Latella edited this page Mar 4, 2019
·
15 revisions
- Importing SWC
- Click import SWC file
- Include Code
- Initialize the API
/**
* Logger initializes the API. You must create GDApi first before doing anything else.
* It is a singleton class.
* @param gID Your game id from GameDistribution
* @param guid Your game guid from GameDistribution
* @param root Should be root to detect the page
*/
GDLogger({gid:gID,userid : guid, root : DisplayObject});
/**
* API sends how many times 'Play Button' is clicked. If you invoke 'PlayGame' many times,
* it increases 'PlayGame' counter and sends this counter value.
*/
PlayGame();
/**
* API sends how many times 'CustomLog' that is called related to given by _key name.
* If you invoke 'CustomLog' many times, it increases 'CustomLog' counter and
* sends this counter value.
*/
* @param _key Your custom key it should be maximum 10 chars
*/
CustomLog(_key:String);
/**
* API reshows banner. For example you need to show banner
* before starting a level, you can call ShowBanner({_key:"level1"}),
* if you need to show sample banner for ONLY test purpose,
* call ShowBanner({test:true})
*/
* @param _key It should be maximum 10 chars
*/
ShowBanner({_key:"keyword"});
/**
* It closes Banner
*/
CloseBanner();
/**
* Sets the API to use SSL-only for all communication
*/
SetSSL();
/**
* Set Blocked Screen Text.
*/
BlockText = "Please visit our site www.GameDistribution.com";
/**
* Triggered by block links checking state
*/
GDEvent.SITE_NOTALLOWED
/**
* Triggered by your game localy running state
*/
GDEvent.RUNNING_LOCAL
/**
* Banner is started
*/
GDEvent.BANNER_STARTED
/**
* Banner is recieved from the server
*/
GDEvent.BANNER_RECEIVED
/**
* Banner is closed
*/
GDEvent.BANNER_CLOSED
/**
* API is not loaded
*/
GDEvent.API_NOTLOADED
After API integration, the game is supposed to be run for a while (approximately 15-30secs) in order to send the first visit request our servers so that we can validate your game has our api correctly. After this validation , "hasApi checkmark" on gamedistribution panel will be checked.
/**
* Events Example
*/
// Game constructor
public function Main()
{
// GD Analytics
var GdAPI = new GDLogger({gid:"1e913e1b06ead0b66e30b6867bf63549",userid : "82b343c2-7535-41f8-a620-c518e96de8f6-s1", root : root});
GdAPI.BlockText = "Please visit our site <a href='www.gamedistribution.com'>www.gamedistribution.com</a>";
GdAPI.addEventListener(GDEvent.BANNER_CLOSED,onBannerClosed);
GdAPI.addEventListener(GDEvent.BANNER_STARTED,onBannerStarted);
GdAPI.addEventListener(GDEvent.BANNER_RECEIVED,onBannerReceived);
GdAPI.addEventListener(GDEvent.SITE_NOTALLOWED,onAllowedLinks);
GdAPI.addEventListener(GDEvent.RUNNING_LOCAL,onRunningLocal);
GdAPI.addEventListener(GDEvent.API_NOTLOADED,onApiNotLoaded);
GdAPI.EnabledDebug = true;
// Game Init.
GameInit();
}
private function onApiNotLoaded(e:Event):void
{
GameResume(); // When API is not loaded, resume game.
}
private function onBannerClosed(e:Event):void
{
GameResume(); // You can resume your game
}
private function onBannerStarted(e:Event):void
{
GamePause(); // You can stop or pause your game
}
private function onBannerReceived(e:GDEvent):void
{
Log("Banner received...\nDimensions:" + e.data.dimensions+ "\nTime:"+e.data.remainingTime+ "\nisInterstitial:"+e.data.isInterstitial);
}
private function onAllowedLinks(e:Event):void
{
GameStop(); // If links are not blocked by web site, you can stop or pause your game
}
private function onRunningLocal(e:Event):void
{
trace("Game is locally running..");
}
/**
* Banner Example
* It fires the banner after timeout period. You cannot invoke method every calling of function.
*/
private function ShowLevelBanner(level:int):void
{
GdAPI.ShowBanner({_key:"level"+level});
}




