Home
Fusion 2.5+
Firefly+
Tutorials+
Videos+
Guides & Tips+
Extensions
Versions
Teaching


Faulty Flap: Annex. Google Play

Annex. Making the game social with Google Play

This tutorial was written by:
Olivier Behr

Implementing social features in your game is important, they foster its viral distribution.

 

Prerequisites:

 

Leaderboards

Name Score formatting Ordering
High Scores Numeric Larger is better

 

 

 

 

Achievements

Name Description Incremental Initial state
First Score Score for the first time. No Revealed
1-Stripe Medal Score 30 points or more. No Revealed
2-Stripe Medal Score 60 points or more. No Revealed
3-Stripe Medal Score 90 points or more. No Revealed
Super Loser Lose 100 times or more. 100 steps Hidden

 

 

 

 

 

 

 

 

 

Frame Editor Icon In the Frame Editor open the Create new object Dialog box by double-clicking on an empty place of the Frame. Then select the 3 objects below and drop them anywhere outside of the Frame.

 

  • GPG Connect: manages the connection to Google Play
  • GPG Leaderboards: manages the leaderboards
  • GPG Achievements: manages the achievements

 

These objects allow your application to communicate with Google Play.

 

Select GPG Connect and click on Properties > Settings tab. Copy your Application ID and paste it in the Application ID field. Also check Automatically login at start.

You can find your Application ID at any time in the Google Play Developer Console > Game services. Look for the 12-or-13-digit number located next to your game's display name at the top of the page.
For more information please check the Help file of the GPG Connect object.

Build And Run Icon Build and run the Android application. The game automatically attempts to sign you in, from the first moments.

 

Event List Editor Icon In the Event List Editor add the following event in the Game.Init group:

Game.Init
Leaderboard
  • Start of Frame

(GPG Leaderboards) : Set leaderboard Id to "LEADERBOARD_ID"

What happens with this event? At the beginning of the game we initialize GPG Leaderboards with a leaderboard identifier so that the object refers to the corresponding leaderboard in subsequent events.
Replace the dummy identifier by the one corresponding to your leaderboard.

You can find the identifier of your leaderboard(s) at any time in the Google Play Developer Console > Game services > Your Application > Leaderboards.

Modify the following event in the Game.Outro group:

Game.Outro
Best score
  • (hud-score-big.Counter) > bestScore

+ Only one action when event loops

: Set bestScore to value( " (hud-score-big.Counter)" )

(hud-best.Counter) : Set Counter to bestScore

: Create (hud-new.Active) at (12,13) from (hud-panel.Active)

(hud-new.Active) : Flash during 00"-20

(GPG Leaderboards) : Submit score with fixed value bestScore

What happens with this event? In addition to what we already did at Step 6, now we also submit the score of the player to Google Play.
We submit a value with the Numeric score formatting because that's what we want to use in this game, the leaderboard is set to Numeric in the Google Play Developer Console. In other games you could use another score formatting like Time or Currency.

Now we need to provide the player with a way to display the scores stored into the leaderboard. At the same time we will also provide him with a way to display his achievements.

 

Frame Editor Icon In the Frame Editor > Layers Toolbar make sure that Layer 3 is selected. From the Library Window drag the 2 objects below anywhere outside of the Frame.

 

  • btn-leaderboards.Active: "Leaderboards" button
  • btn-achievements.Active: "Achievements" button

 

Because we only need to display these objects at the end of the game, they are set to not Create at start.

 

Event List Editor Icon In the Event List Editor add the following event in the Game.Outro group:

Game.Outro
Init
  • (GPG Connect) is local player authenticated?

+ Only one action when event loops

: Create (btn-leaderboards.Active) at (326,518) layer 3

: Create (btn-leaderboards.Active) at (156,518) layer 3

What happens with this event? Once that the Game.Outro group is activated, if the local player is authenticated we display the "Leaderboards" and "Achievements" buttons.
If the local player is not authenticated, i.e. connected to his Google Play account, it is unnecessary to display the buttons because they would have no effect.

Now add the following events in the Game.Outro group:

Game.Outro
Display leaderboard then display achievements
  • User clicks with left button on (btn-leaderboards.Active)

 (GPG Leaderboards) : Display Leaderboard UI

  • User clicks with left button on (btn-achievements.Active)

 (GPG Leaderboards) : Display Achievements

What happens with these events? When the player clicks on the "Leaderboards" button we display the leaderboards built-in UI, and when the player clicks on the "Achievements" button we display the achievements built-in UI. Simple.

Build And Run Icon Build and run the Android application. When you lose the game, and provided that you're signed in to your Google Play account, the two additional buttons appear.
Tap on the "Leaderboards" button and you should see your greatest score. Tap on the "Achievements" button and you should see that all of them are locked.

 

Event List Editor Icon Let's reward the player with these achievements. In the Event List Editor add the following events in the Game.Outrogroup:

Game.Outro
Init
  • (hud-score-big.Counter) > 0

+ Only one action when event loops

(GPG Achievements) : Unlock achievement Id "FIRSTSCORE_ACH_ID"

  • Only one action when event loops

(GPG Achievements) : Incremenet achievement Id "SUPERLOSER_ACH_ID" with steps 1

What happens with these events? If the score of the player is greater than zero we unlock the "First Score" achievement. Because an achievement can only be unlocked once it doesn't matter that we unlock it every time that the player loses.
We also increment the "Super Loser" achievement by 1 every time that the player loses. In other words we keep track of how many times the player loses. Once that this incremental achievement reaches 100 steps, as defined in the Google Play Developer Console, it will be automatically unlocked.
Replace the dummy identifiers by the ones corresponding to your achievements.

You can find the identifier of your achievement(s) at any time in the Google Play Developer Console > Game services > Your Application > Achievements.

Build And Run Icon Build and run the Android application. When you lose the game the "First Score" achievement is unlocked. You'll need more time to unlock the "Super Loser" achievement. For faster testing you could change the value of the increment or the number of steps in the Google Play Developer Console.

 

Event List Editor Icon We're almost done with the achievements. In the Event List Editor modify the following events in the Game.Outrogroup:

Game.Outro
Medal
  • (hud-score-big.Counter) >= 30

+ Only one action when event loops

: Create (hud-medal.Active) at (-80,8) from (hud-panel.Active)

(GPG Achievements) : Unlock achievement Id "MEDAL1_ACH_ID"

  • (hud-score-big.Counter) >= 60

+ Only one action when event loops

(hud-medal.Active) : Set direction to 1

(GPG Achievements) : Unlock achievement Id "MEDAL2_ACH_ID"

  • (hud-score-big.Counter) >= 90

+ Only one action when event loops

(hud-medal.Active) : Set direction to 2

(GPG Achievements) : Unlock achievement Id "MEDAL3_ACH_ID"

What happens with these events? In addition to what we already did at Step 6, now we also unlock a different achievement depending on the score of the player.
Replace the dummy identifiers by the ones corresponding to your achievements.

Build And Run Icon Build and run the Android application and try to unlock the remaining achievements!




Spread the word!



You can share this document using the following buttons.




Submit your own User Tip