Defold on Facebook Instant Games

#1

Hi everyone!

I’m currently thinking about using Defold to develop instant games. However, I can’t seem to find any games that have already been released on the platform.
I might just be bad on finding things. So I wanted to check if anyone already made a game on instant.

Cheers!

2 Likes

#2

Hi! I’ve been looking into the different instant games platforms and I believe Defold is in a really good position to work as the engine for instant games. Defold is already quite lean, and thanks to the app manifest you can reduce the engine size even further.

There are numerous instant games platforms; Facebook Instant Games, Apple iMessage and Telegram to mention a few. Which platform were you thinking of specifically?

Most (all) instant games platforms build their offering around HTML5 and since we have good support for HTML5 and also native extension support for HTML5 there really should be no problem for you to wrap an instant games SDK and expose its API via Lua.

8 Likes

#3

Thank you, britzl!
Today is my first day ever with Defold, so excuse me if I post some real noob questions here.

Defold is already quite lean, and thanks to the app manifest you can reduce the engine size even further.

You mean you can change the amount of RAM? Or something else?

Which platform were you thinking of specifically?

I wanted to start with Facebook Instant. I was trying to find any game that was done on Defold on Instant just for a quick benchmark with other frameworks. I haven’t found any so far. If anyone knows about some Defold games on the instant, please let me know :slight_smile:

HTML5 there really should be no problem for you to wrap an instant games SDK and expose its API via Lua.

I don’t know much about the native extension support for HTML5, but if I just want to include a JS library I would need to port it to C++ first if I go this way, right?

I also looked at how to call JS code from within Lua, and I think it would always be something like

result = execJS("functionName");

That way we would need to include the FBInstant library inside the HTML page or, create some placeholder functions in the HTML page that call the library - with a small façade API it should be easier to maintain.

After that we would need to call the JS code that exists inside the <script> blocks within our Lua files, maybe even creating a bindings_instant. lua file to handle this.

Is my reasoning close to what you would do?

Thanks again!

0 Likes

#4

He means lean as in the runtime is very small to download. Just over or under 1MB for HTML5 I think is possible? But the runtime size is also small, lean, and fast too.

Defold prepares the amount of resources it uses in advance and for HTML target you can set a custom heap size in your game.project file just make sure it’s enough for your game, but the default value (256MB) may be higher than you need.

You do not need to port JS libs to C++. You can make a JS wrapper and talk to this wrapper with html5.run() if there are callbacks you can use html5.run() to poll a callback queue to work through. If you don’t need those sorts of things you can use html5.run() to run JS directly.

2 Likes

#5

You can reduce the size of the engine on disk. A gzipped slightly stripped version of the engine for HTML5 weighs in at ~800kb or something like that. You obviously need to add your assets and code to that size, but with some clever user of texture compression and perhaps also our live update feature it’s possible to keep the initial download size down.

Read more here: Native Extensions
And tools to generate app manifests: Stripping appmanifest maker

Are you part of the Facebook Instant Games beta?

The amount of FB Instant Games is still quite low. I’m not aware of any released games but I know of one studio exploring instant games using Defold.

No. You’d still create the “glue code” in C to set up bindings between Lua and C and then onwards to native code for the target platform, in this case Javascript. There’s HTML5 native extension examples here: https://github.com/defold/extension-html5

You could use html5.run() but I think you’ll struggle a bit with the async calls of an instant games sdk.

6 Likes

#6

Excellent, thank you!

Yes sir

Makes sense, we would need to handle all promises on JS and make sure we’re not calling something that is returning a promise on Lua. Also following this logic, I only need to do the JS>C>Lua one time and use it for multiple projects.

Thanks for those very useful pieces of information. I think I have enough to start making something :slight_smile:

Cheers!

1 Like

#7

Please get in touch with me via e-mail (bjorn.ritzl@king.com) to discuss further. I may have some things that help you get started.

5 Likes

#8

Now open for all developers :smiley:

3 Likes

#9

Found my own answer here:

:smiley: :smiley:

5 Likes

#10

Yes, we’re rolling out support for instant games using Defold. This time we decided to create an official native extension instead of a closer integration like we did for Gameroom. There’s still a few things to improve in the extension but it’s fully functional and we encourage you guys to start considering Instant Games as a platform to launch games on.

7 Likes

#11

I like this approach too because it means down the road you could potentially accept pull requests.

1 Like

#12

As I know (at least when I used instant 2.1) facebook sdk no need, when you use fb instant games.
I want to remove FB sdk using appmanifest, but fb instant has no some methods, like logEvent( ).
Do you have plans to add this methods to instant games sdk?

0 Likes

#13

Yes, absolutely! I want 1:1 mapping of functionality. I must have missed logEvent(). Note: The Leaderboard functions are currently also missing. They’ll be added next week.

1 Like

#14

I am looking forward to AD metods =)))

0 Likes

#15

I’ve started work on this: https://github.com/defold/extension-fbinstant/blob/master/fbinstant/src/fbinstant.cpp#L911-L912

But since ads are currently only supported on mobile it’s hard to debug.

3 Likes

#16

It looks like even though this is public for everyone now monetization options still are not? Like with rewarded videos https://developers.facebook.com/docs/games/instant-games/guides/ads-monetization

Or do we just use the placement id for android/ios?

It looks like we have to detect the platform with FBInstant.getSupportedAPIs() and then use the Android/iOS key. Ads are not supported on direct web version?

I’ll be reading all of the docs this weekend…

“If the game is being played in the Facebook main app ads are not currently supported. We’re currently working on changing that.”

So ads only currently work if users play in the Messenger app only.

dash

3 Likes

#17

Yes. Ads are only supported on mobile currently. The pace of new releases and new functionality has been high so I expect ads on desktop to be available soon. Then there’s also in app purchases but that’s in closed beta.

3 Likes

#18

I’m going to put up my Minesweeper clone this weekend to go through all the steps. Still getting my brother into using Defold and making some smaller Facebook IG with him may be good tutorials.

5 Likes

#19

please poke me if you do it by Wed/Thu, I’ll go to FB booth here at GDC to pitch Defold IGames to Facebook folks.

2 Likes

#20

It’s almost ready so should be… only changing one thing… making it turn based 2 player. :bomb: :rofl:

2 Likes