class flixel.addons.api.FlxKongregate

Available on all platforms

Allows for easy access to the Kongregate API * * Todo: Add in the functions for Chat Integration - you can still use them via the FlxKongregate.api object. * * @link http://www.photonstorm.com * @author Richard Davey / Photon Storm

Class Fields

static var api:Dynamic

The Kongregate API object. You can make calls directly to this once the API has connected.

static var hasLoaded:Bool

True if the API has loaded otherwise false. Loaded is not the same thing as connected, it just means it's ready for the connection.

static var isLocal:Bool

Is the game running locally in Shadow API mode (true) or from Kongregates servers (false)

static function addEventListener(ContentType:String, Callback:Void ->Void):Void

Register an event listener with the API. Useful for capturing guest to user login requests for example. * See: http://www.kongregate.com/developer_center/docs/handling-guests * *

ContentType

The event to listen for (i.e. "login") *

Callback

Funcation to call when this event is received

static function addLoadListener(ContentType:String, Callback:Void ->Void):Void

Use the addLoadListener function to register an event listener which will be triggered when content of the specified type is loaded by the user. * These MUST be set-up before you call FlxKongregate.connect() * See: http://www.kongregate.com/developer_center/docs/shared-content-api * *

ContentType

Type of content to listen for *

Callback

Function to call when content load request has been made

static function browseSharedContent(ContentType:String, ?SortOrder:String = null, ?Label:String = null):Void

The browse function causes a list of shared content to appear in the user's browser. * This will allow them to view, rate, or load shared content for your game. * See: http://www.kongregate.com/developer_center/docs/shared-content-api * *

ContentType

Type of content to browse *

SortOrder

Optional constant specifying how to sort content (see API docs) *

Label

Optional, only browse content saved with the specified label

static function connect():Void

Connect to the Kongregate API. This should be called only after the init callback reports a succesful load of the API

static function disconnect():Void

Remove the API from memory (when possible) and removes it from the display list also

static function getGameAuthToken():String

If you are using the Authentication API you can use the getGameAuthToken function to get the player's game authentication token.

static function getUserId():Float

You can use the getUserId() function to retrieve the unique user id of the current player. It will return 0 if the user is not signed in.

static function getUserName():String

You can use the getUsername() function to retrieve the username of the current player. It will begin with Guest if the user is not signed in.

static function init(Callback:Dynamic):Void

Loads the Kongregate API and if successful connects to the service. * Note that your game must have access to Stage by this point. * *

Callback

This function is called if the API loads successfully. Do not call any API function until this has happened.

static function isGuest():Bool

The isGuest function can be called to determine if the player is currently signed into Kongregate or not

static function purchaseItem(Items:Array<Dynamic>, Callback:Void ->Void):Void

Bring up the "purchase items" dialog box by using the purchaseItems method on the microtransaction services object. * Your game must be in the Kongregate Microtransactions beta to use this function. * See: http://www.kongregate.com/developer_center/docs/microtransaction-client-api * *

Items

The array of item identifier strings or item/metadata objects. *

Callback

The callback function

static function requestUserItemList(Username:String, Callback:Void ->Void):Void

Request the inventory of any user. * Your game must be in the Kongregate Microtransactions beta to use this function. * See: http://www.kongregate.com/developer_center/docs/microtransaction-client-api * *

Username

The username to request inventory for, or null for the current player *

Callback

The callback function

static function resizeGame(Width:Int, Height:Int):Void

If you need to resize your game's enclosing container, you may do so with resizeGame call. The enclosing iframe will resize around your game. * Games may not be resized smaller than their initial dimensions. This call requires special permission from Kongregate to use. * *

Width

New width (in pixels) of the container *

Height

New height (in pixels) of the container

static function saveSharedContent(ContentType:String, Content:String, Callback:Void ->Void, ?Thumb:DisplayObject = null, ?Label:String = null):Void

Use the save function to submit shared content on the Kongregate back-end. * See: http://www.kongregate.com/developer_center/docs/shared-content-api * *

ContentType

Type of content the user wishes to save, 12 characters max. *

Content

Value of content to be saved. We strongly recommend keeping these values under 100K. *

Callback

Function to call when save has finished. *

Thumb

Optional but highly recommended! Send us a DisplayObject that we will snapshotted and used as a thumbnail for the content. *

Label

Optional, label for sub-classing the shared content.

static function showKredPurchaseDialog(PurchaseMethod:String):Void

Display the Kred purchasing Dialog. * Your game must be in the Kongregate Microtransactions beta to use this function. * See: http://www.kongregate.com/developer_center/docs/microtransaction-client-api * *

PurchaseMethod

The purchase method to display. Should be "offers" or "mobile"

static function showRegistrationBox():Void

This call works the same way as showSigninBox, but it focuses the registration form rather than the sign-in form.

static function showShoutBox(?Message:String = ''):Void

If a player is logged-in and you want to allow them to post a shout on their profile page, you may bring up the shout box, optionally populated with some initial content. * *

Message

The optional initial content

static function showSignInBox():Void

If the player is a guest, and you want to display the sign-in/registration UI to them you can use the showSignInBox function.

static function submitAvatar(Avatar:DisplayObject, Callback:Void ->Void):Void

Export a DisplayObject to be converted to a user avatar. It is highly recommended that avatars be at least 40 x 40px. * See: http://www.kongregate.com/developer_center/docs/avatar-api * *

Avatar

Can be null, but highly recommended that you send yourself. If null, we will snapshot the stage. *

Callback

Function to call when content load request has been made

static function submitScore(Score:Float, Mode:String):Void

Submit a score to the Kongregate server. Make sure you have defined the stat before calling this. * See the Kongregate API documentation for details. * *

Score

The value of the score *

Mode

What game mode this score is for, like "Hard" or "Normal"

static function submitStats(Name:String, Value:Float):Void

Submit a statistic to the Kongregate server. Make sure you have defined the stat before calling this. * See the Kongregate API documentation for details. * *

Name

The name of the statistic *

Value

The value to submit (will be converted to an integer server-side)