Comments (5)
There is a "mock" api included in the example https://origincache.facebook.com/developers/resources/?id=tic-tac-toe.zip
fbinstant.6.0.mock.js.txt
It returns dummy values to all function calls. Could detect if the domain is localhost, and then load the dummy api instead. That way building Instant Game apps with Defold would be easier doing Project -> Build HTML in the editor.
from extension-fbinstant.
Do you have some more information about this?
from extension-fbinstant.
Ah, I see. Ok, so that mocks the fbinstant js api. That might be useful.
I actually also provide a mock version of the fbinstant.* namespace for rapid testing on desktop, without the need to build/bundle to HTML5. It's a pure-Lua implementation of the fbinstant.* functions with static responses (no backend or anything like that involved). I'm not sure if I want to document it since I'm not sure of its usefulness yet. The mock version is in fbinstant.utils.mock.lua
. require() it in a main/loader script before calling any fbinstant functions and give it some dummy data about the player(s) and context:
-- mock fbinstant.* to test your game without the need to build/bundle for HTML5
require "fbinstant.utils.mock"
-- this will be true on non HTML5 builds
if fbinstant.mock then
-- this is the logged in player
fbinstant.PLAYER = {
name = "Player 1",
id = "100000000001fake",
photo = "http://i.pravatar.cc/200?u=123",
locale = "en_US",
}
-- these are the players in the current context (fbinstant.get_players())
fbinstant.PLAYERS = {
fbinstant.PLAYER,
{
name = "Player 2",
id = "100000000002fake",
photo = "http://i.pravatar.cc/200?u=456",
locale = "en_US",
}
}
-- the current context
fbinstant.CONTEXT = {
id = "123456fake",
type = fbinstant.CONTEXT_THREAD,
size = 2,
}
end
from extension-fbinstant.
Desktop builds are faster than HTML5 so it would be useful too. The problem I see is needing to update so many things as the API changes.
I'm going to go all in on making some big Facebook Instant Games (and port some in progress projects to it) so anything to help productivity will be useful and I bet others will appreciate it too!
Another thing which may be useful would be a chrome extension or js include which can detect new builds somehow and autoreload the web page... I've used something like that with other tools before. Another way to do it would be to make the build script open a fresh page but have a for example Chrome extension auto close other tabs of the specified name...
from extension-fbinstant.
I can't imagine that Facebook would make many API changes now that the API is public. Sure, they may deprecate functions and add new ones, but the ones that are documented now are not likely to change.
It would be quite useful if Facebook provided this mock API somewhere more accessible, instead of hidden away inside a zip. Or if they provided an API definition in a parsable format so that something like my mock.lua file could be autogenerated much in the same way as Amazon provides API definitions for the AWS SDK.
from extension-fbinstant.
Related Issues (20)
- Add FBInstant.switchGameAsync
- Need to change example from now no longer working activity stores into using web server (heroku) based cloud save for context data HOT 3
- Chat bot example
- Mock doesn't contain rewarded video mock functions HOT 2
- Add In-app purchase support HOT 3
- Loading rewarded video throws CLIENT_UNSUPPORTED_OPERATION HOT 11
- Ads not loading more than once HOT 3
- set_leaderboard_score fails if extra_data is omitted
- Incompatible with Defold 1.2.148 HOT 1
- choose_context fails if optional "options" parameter is omitted HOT 3
- Expose more error code constants and return them in the callbacks
- fbinstant.set_leaderboard_score fails silently HOT 5
- Index.html fails to build HOT 2
- Update to FBInstant API 6.3 HOT 1
- Add support for matchPlayerAsync( ) HOT 4
- Add script API for editor auto-complete
- fbinstant.log_event() fails if optional value(s) are omitted HOT 5
- The callback for fbinstant.share() doesn't trigger "when the share dialog has been closed" HOT 3
- Use the new Defold SDK callback functions HOT 1
- Allow custom HTML access to updateProgress and initializeAsync
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from extension-fbinstant.