How to Add Facebook Instant Games Leaderboards with 2DKit Tutorial

How to Add Facebook Instant Games Leaderboards with 2DKit Tutorial

This tutorial will show you how to add leaderboards to your Facebook Instant Games with 2DKit.

“Leaderboards provide a key retention mechanic for simpler score based games. Instant Games support leaderboards and leaderboard updates besides custom updates.”

https://developers.facebook.com/docs/games/instant-games/guides/using-leaderboards

Let’s get started!

Facebook Instant Games Tutorial for 2DKit

Facebook Instant Games Tutorial for 2DKit

Prerequisites

You will need the following to get started using 2DKit for Facebook Instant Games–

  1. Facebook developer account

  2. The latest version of 2DKit

 

Adapting Existing 2DKit Games to the Facebook Instant Games platform

You can get an existing 2DKit game running on the Facebook Instant Games platform in a few minutes with the following 4 steps.

Details about each of these steps follow below.

1) Check your project’s 2DKit.yaml and make sure you have entered the app_id and upload_token.

fbinstant:
app_id: ADD_YOUR_APP_ID_HERE
upload_token: ADD_YOUR_UPLOAD_TOKEN_HERE

2) For code-only (non Creator) projects call System.initPlatformSDK().

3) Run the command 2dk run fbinstant to preview your game locally.

4) Run the command 2dk publish fbinstant to upload your game and then push it to production in the dashboard.

 

Setup a new app using the Facebook.com Dashboard

Before getting started create a new app for the Facebook Instant Games platform using this guide.

https://developers.facebook.com/docs/games/instant-games/getting-started/quickstart#app-setup

Make sure to note the app_id, upload token, and orientation(portrait or landscape) for the next step.

 

Using the FBInstant SDK for ads, sharing, leaderboards, and more

2DKit supports the entire FBInstant SDK, which allows you to use features specific to the Facebook Instant Games platform like monetizing with ads, leaderboards, matchmaking, cloud-based data, localization, and more.   You can find documentation about the 2DKit-compatible FBInstant SDK here–

http://developer.2dkit.com/api/fbinstant/

 

 

Building, Publishing, and Code Completion with Visual Studio Code

The Facebook Instant Games platform is supported for all 2DKit-compatible code editors.  Here is an example of how to work with Facebook Instant Games in Visual Studio Code.

From a command prompt change to a 2DKit project directory, and then run this command to create the project files–

2dk generate visual-studio-code

 

You should now see code completion working in Visual Studio Code.

 

To run your FBInstant project from Visual Studio Code select Tasks->Run Task

 

Then select Facebook Instant to run your game locally in the Facebook Embedder.

 

Learn more about using Visual Studio Code for 2DKit projects.

http://developer.2dkit.com/developers/tutorials/2dkit-visual-studio-code-guide/

Testing Your Facebook Instant Game Locally

The following guide explains in detail how to test your Facebook Instant Game on your local computer in the Facebook Embedder–

http://developer.2dkit.com/2dkit-facebook-instant-games-local-testing-guide/

 

 

Automatically Uploading and Publishing your App

2DKit allows you upload and publish your Facebook Instant Game directly from 2DKit in one step.

1)From the terminal run this command and 2DKit will build your game zip and upload your game directly to Facebook web hosting.

2dk publish fbinstant

 

2) After your app’s zip is uploaded the web hosting page will automatically open.  Then click the star button to select the version you just uploaded as the production version so you can test the game on your device.

https://developers.facebook.com/apps/{YOUR_APP_ID}/hosting

 

3) After you do this you will see this version available in the Facebook Messenger app where you can tap to play it.

 

 

 

Creating Facebook Instant Games with 2DKit

Easily Create Facebook Instant Games with 2DKit

Facebook Instant Games Benefits

  • Get your 2DKit games on Facebook Instant Games platform in minutes

  • Monetize and distribute your games to more  than 1 billion users

  • Use 2DKit’s FBInstant SDK to easily add features like sharing, leaderboards, analytics, localization, and multiplayer to your games

  • Lightweight HTML5 game engine footprint (~50 KB!) enables games to load almost instantly
  • Turn-key visual components ease development (eg. LeaderboardWidget)

2DKit Facebook Instant Games Overview

Facebook’s Instant Games platform is a great opportunity to monetize and distribute your games to over 1 billion users using the tools and experience you already have as game developers.

HTML5 game developer, FRVR, is a good example of the potential of the platform.  Their game Basketball FRVR, is on track to make over 7-digits in ad revenue annually, and has been played over 4.2 billion times.  You can read more about their story here–

https://developers.facebook.com/success-stories/frvr/

The goals of Facebook’s new platform align perfectly with what 2DKit was created to do–enable the creation premium quality cross-platform gaming content that can reach and monetize the largest audience possible.

2DKit Facebook Instant Games Features

  • Monetize with rewarded video and interstitial ads

  • Reach wider Lightweight audience leveraging 2DKit’s optimized file sizes and fast Canvas performance

  • Automatically preview locally in the Facebook Embedder

  • Automatically upload and publish to Facebook’s web hosting

  • Auto-initialization for FBInstant platform

  • FBInstant SDK is completely supported with code completion and navigation in your favorite code editors

  • Tutorials and samples to learn about working with FBInstant features

  • Streamlined project configuration process

  • Easily setup existing 2DKit projects for Facebook Instant Games platform

  • Turn-key visual components make developing Instant Games easy (eg. LeaderboardWidget)

Get Started with 2DKit Facebook Instant Games in Minutes

You can get an existing 2DKit game running on the Facebook Instant Games platform in a few minutes with the following 4 steps.

1) Add the Facebook app_id and upload_token to your 2DKit.yaml.

2) Call System.initPlatformSDK().  (Only needed for code-only projects.)

3) Run the command 2dk run fbinstant to preview your game locally.

4) Run the command 2dk publish fbinstant to upload your game and then push it to production in the dashboard.

Check out the quick start guide for everything you need to get started with using 2DKit to make and publish Facebook Instant Games.

Learn More

 

How to Add Facebook Instant Games In-App Purchases with 2DKit Tutorial

How to Add Facebook Instant Games In-App Purchases with 2DKit Tutorial

This tutorial will show you how to use in-app purchases to monetize your Facebook Instant Games with 2DKit.

“Instant Games In-App Purchases (IAP) provides a way for developers to to leverage micro-transactions in their Instant Games on Facebook.com and Messenger for Android. Developers will be able to immediately test IAP in their games. Once a game has passed through In App Purchase review, players will be able to make purchases on Android and Facebook.com.”

https://developers.facebook.com/docs/games/instant-games/guides/in-app-purchases

Let’s get started!

How to Use 2DKit’s Camera System to Handle Pan, Zoom, Follow, and Parallax

How to Use 2DKit’s Camera System to Handle Pan, Zoom, Follow, and Parallax

This tutorial will show you how to use the Camera System to handle pan, zoom, follow, and parallax using 2DKit, a powerful HTML5 game engine, .

Let’s get started!

How to Create a Trippy Render Textures Effect with 2DKit

How to Create a Trippy Render Textures Effect with 2DKit

This tutorial will show you how to create a trippy render textures effect with 2DKit, a powerful HTML5 game engine.

Let’s get started!

How to Create an Alpha Mask Reveal Effect with 2DKit

How to Create an Alpha Mask Reveal Effect with 2DKit

This tutorial will show you how to create an alpha mask reveal effect with 2DKit, a powerful HTML5 game engine.

Let’s get started!

How to Handle Simple AABB Collision Detection in 2DKit

How to Handle Simple AABB Collision Detection in 2DKit

This tutorial will show you how to handle simple AABB collision detection in 2DKit, a powerful HTML5 game engine.

Let’s get started!

How to Work with Depth Sorting ( Z-index Sorting ) in 2DKit

How to Work with Depth Sorting ( Z-index Sorting ) in 2DKit

This tutorial will show you how to work with depth sorting (z-index sorting) in 2DKit, a powerful HTML5 game engine.

Let’s get started!

How to Work with Retina and HiDPI assets in 2DKit

How to Work with Retina and HiDPI assets in 2DKit

This tutorial will show you how to work with Retina and HiDPI assets in 2DKit, a powerful HTML5 game engine.

Let’s get started!