Integration

The Flash plugin aims to make it easier to integrate GameAPI in Flash games. Please make sure that you meet the requirements.

  1. Include Game API files to your project
  2. Load the Game API
  3. Check for Site Lock if it is part of your contract with Spil
  4. Add Logo
  5. Add Promotional buttons (More games, App Store, Google Play, Facebook buttons)
  6. Implement Game Breaks
  7. Send scores to our back-end
  8. Grant awards to the players
  9. Test your integration

 

Disclaimer!

If you agreed with us to use our previous flash technology called Flash API please follow the documentation here.

IMPORTANT for testing!

For retrieving the correct configurations on the test tool, you need to add your GAME ID at the end of the test tool URL:
http://cdn.gameplayer.io/testtool/index.html#!/tester/GAME_ID

You will receive your GAME ID from your Spil Game Producer. For the following example the right URL would be: http://cdn.gameplayer.io/testtool/index.html#!/tester/576742227280291016

This way you make sure that your game will retrieve the correct configurations when you are testing.

 

1. Include Game API

DOWNLOAD the API file and unzip it. Then just include the folder to the source folder of your project as it is.

 

2. Load Game API

Load the API in the example.
ATTENTION: Make sure the API is loaded before you start using any other API call. To do that you will need to wait for the function onLoadComplete(e:Event) to be executed.

import com.spilgames.gameapi.GameAPI;

var gameAPI:GameAPI = GameAPI.getInstance();

// once the COMPLETE event is dispatch by GameAPI you can make the calls
gameAPI.addEventListener(Event.COMPLETE, onLoadComplete)

// pass a String containing the GAME ID you will receive from the game producer you are
// in contact with and a reference to Flash's Stage
gameAPI.loadAPI("576742227280291016", stage);

public function onLoadComplete(e:Event):void
{
// you can start using Spil Games GameAPI
}

 

3. Check for Site Lock

If your game is required to be site locked for Spil’s portals and partners you can use the isSiteLock call from the API in order to make the check.

The call will not lock the game, but return a Boolean value indicating if the game should be allowed to run or not. The call must be triggered after the API is loaded.

import com.spilgames.gameapi.GameAPI;

var gameAPI:GameAPI = GameAPI.getInstance();

if (gameAPI.Game.isSiteLock())
{
// the game should be site locked and not run
}

 

4. Add Logo

Add the logo to your game after the API is loaded.

import com.spilgames.gameapi.GameAPI;
import com.spilgames.gameapi.components.GameAPIBtn;
import com.spilgames.gameapi.components.Logo;

// the API logo Object extends Display Object and can be handled as such
// it already has its click handler from GameAPI implemented
var logo:Logo = GameAPI.getInstance().Branding.getLogo();
logo.x = stage.width - 250;
addChild(logo);

5. Add Promotional Buttons

Promotional Buttons are buttons that the players can click and lead to the mobile app of the game, social media of the game, offered more games or to other games of your game series. The table below sums up the possibilities. Of course you can create your own (Facebook,twitter) in coordination with your Spil Game Producer.

Button Shall I include it to my game? Code tag
More games Yes more_games
App Store If the game is also on App Store app_store
Google Play If the game is also on Google Play  google_play
Facebook If the game has a link to a Facebook page facebook_like
Twitter If the game is also on Google Play  twitter_share
My game 1 If your game is a part of a game series, make buttons to link to the rest of your games for example: Snail Bob 1, Snail Bob 2, Snail Bob 3 and so on or
Let’s Fish 1, Let’s Fish 2 or
König der Türme 1, König der Türme 2.

Note: The tags should be all lower case. Do not use special characters or apostrophes even if it’s part of the title.

my_game_X

for example: snail_bob_1,
snail_bob_2 or
lets_fish_1,
lets_fish_2 or
konig_der_turme_1,
konig_der_turme_2

 

import com.spilgames.gameapi.GameAPI;
import com.spilgames.gameapi.components.GameAPIBtn;
import com.spilgames.gameapi.components.Logo;

//for more games button you have to create an image yourself
//when the button is pressed you can trigger with the call below
GameAPI.getInstance().Branding.getLink("more_games").action();

// if your game has promotional links set up in Spil Games backend with
// images configured, you can use the GameAPIBtn class just like the API logo
var appstore:Sprite = GameAPI.getInstance().Branding.getLink("app_store");
appstore.x = stage.width - 250;
appstore.y = 100;
addChild(appstore);

// if your game don't have images for a promotional button set on Spil Games backend
// you can still trigger its action by calling it directly, similar to more games button
GameAPI.getInstance().Branding.getLink("app_store").action();

 

6. Game breaks request

During a natural pause in the game flow such as a level change you can add the GameBreak.request call. When a GameBreak is accepted from our side, we are able to pause the game and display external content such as in-game ad, game suggestions or walkthroughs. We make sure that users aren’t exposed to too much advertising and get the most relevant ads.

The call requires two arguments, a method to pause the game and another to resume it. This is in order to ensure that the game will not continue its flow if there is content displayed on top of it. Keep in mind that the resume method will always be called by the API where the pause will only be triggered if there is actual content to be displayed.

import com.spilgames.gameapi.GameAPI;

//Before calling the GameAPI.GameBreak.request method the API must be loaded and ready for use

// This method will be called only if there is content to be displayed on top of the game
private function pauseGame():void
{
// add here the logic to stop the game flow, sound and animations
}

// This method will always be called
private function resumeGame():void
{
// add here the logic to resume the game flow, sound and animations
}

if (GameAPI.getInstance().isReady)
{
GameAPI.getInstance().GameBreak.request(pauseGame, resumeGame);
}

 

7. Send Scores

You can submit the players Score by using the method below.

import com.spilgames.gameapi.GameAPI;

// make sure that GameAPI is initialised and ready
if (GameAPI.getInstance().isReady)
{
GameAPI.getInstance().Score.submit(100);
}

 

8. Grant Awards

In order to grant awards for a player in Spil Games’ network it is necessary to submit a tag for each award. The tags that are acceptable from Spil Games back-end are award1, award2, award3 and so on. The Spil game producer that you are in contact will make sure that these tags match your awards. The tag should be passed as a String parameter to the method call.

import com.spilgames.gameapi.GameAPI;

// make sure that GameAPI is initialised and ready
if (GameAPI.getInstance().isReady)
{
// Grant the first award of your game like the example below.
GameAPI.getInstance().Award.submit("award1");
}

9. Testing your integration

Once you’ve finished implementing all the required features for your game you can test it on the TEST TOOL and remember to place your GAME ID at the end of the URL to get the correct configurations. Make sure that you meet our requirements before you send us your final build for QA.

http://cdn.gameplayer.io/testtool/index.html#!/tester/GAME_ID