In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Today, I would like to talk to you about how to achieve the rapid release of Facebook Mini Game, which may not be well understood by many people. in order to let you know more, the editor has summarized the following for you. I hope you can get something from this article.
Getting started with Mini Game
Set up the application
Even if you already have a web game hosted on Facebook.com or a mobile game hosted on a mobile app store, you need to create a new app for your Mini Game. You can't make a Mini Game using the same Facebook app number as any other app.
Set the category to Game
Go to the basic settings section of the application panel and make sure the category is set to the game. Save your changes.
Add administrators, developers, and testers to the application
Facebook is gradually promoting Mini Game to a wider audience, and your game may not be open to all users at this time. To ensure that all publishers and testers of the game have access, add them as administrators, developers, or testers of the application in the user identity tab of the application panel (see screenshot below). Learn more about the identity of the user.
Enable Mini Game function in the application panel
Please note: do not add Mini Game to existing Facebook applications configured for iOS, Android, or Web environments. The Facebook app number created for Mini Game does not apply to other platforms.
Create a new Facebook application
To enable the * Mini Game function for the app, click the + add item button at the bottom of the navigation menu. This will open the list of available products in the application. Find Mini Game in the list and click the start button. This adds a Mini Game section to the menu. Make sure the switch on the Mini Game platform is turned on. Save your changes and continue.
The first step of SDK
Import
Now that you have set up the application, you need to start creating a game client. An index.html file is required in the root directory of the game client. Please first import Mini Game SDK from this file.
Initialization
Promises is widely used in our SDK to implement asynchronous functionality. You can only interact with the loaded user interface after the FBInstant.initializeAsync () parsing is complete.
FBInstant.initializeAsync ()
.then (function () {
/ / Start loading game assets here
});
Instead of downloading all bundles (.zip files) at once, the game client searches for the configuration root file (fbapp-config.json) and the master file (index.html). After that, it will begin to execute the logic contained in the main file and start downloading assets from here. Developers have full control over the order and timing of asset loading.
After you start downloading the assets needed to initialize the game, you need to inform SDK of the loading progress so that we can show the player the loading progress loop.
Var images = ['sprite1',' sprite2',...]
For (var item0; I
< images.length; i++) { var assetName = images[i]; var progress = ((i+1)/images.length) * 100; game.load.image(assetName); // Informs the SDK of loading progress FBInstant.setLoadingProgress(progress); } // Once all assets are loaded, tells the SDK // to end loading view and start the game FBInstant.startGameAsync() .then(function() { // Retrieving context and player information can only be done // once startGameAsync() resolves var contextId = FBInstant.context.getID(); var contextType = FBInstant.context.getType(); var playerName = FBInstant.player.getName(); var playerPic = FBInstant.player.getPhoto(); var playerId = FBInstant.player.getID(); // Once startGameAsync() resolves it also means the loading view has // been removed and the user can see the game viewport game.start(); }); 如需详细了解 initializeAsync()、setLoadingProgress() 和 startGameAsync() 方法,请参阅 SDK 参考文档。 测试和上传 小游戏内容在 Facebook 基础设施上托管,因此,无需自行托管游戏内容或使用第三方服务。在准备好游戏进行测试后,将所有游戏文件打包为一个 .zip 文件。请注意,index.html 文件应位于此存档的根文件夹中,而不应位于任何子文件夹中。 要上传 .zip 文件,请点击应用面板中的虚拟主机选项卡。从该选项卡的下拉菜单中选择"小游戏",然后单击 +上传版本,即可将 .zip 文件上传到 Facebook 的托管服务中。 之后,构建版本会处理文件,仅需数秒时间。状态更改为"待命"时,单击"★"按钮将构建版本推送到生产。 之后,您可以在移动设备中测试构建版本。现在,在 Messenger 内的游戏列表中,您可以在"开发中"版块下看见已发布的构建版本。为了加快开发流程,您可以参考此指南,了解如何通过图谱 API 从命令行上传构建版本,或者如何直接从开发服务器进行测试:测试、发布和分享小游戏 游戏环境更新 我们已经介绍过使用小游戏 SDK 的基本知识,现在来看看如何让您的游戏与游戏环境互动。 我们用游戏环境一词来定义可以玩游戏的任何环境。更多情况下,游戏环境是指 Messenger 对话,但如果游戏不是在 Messenger 中玩,游戏环境也可以指其他各种位置,例如 Facebook 帖子或小组。 以下示例说明了如何发送游戏环境更新及其在 Messenger 对话中的展示效果。 第 1 步:在配置文件中声明模板 为了声明自定义更新,您需要创建名为 fbapp-config.json 的配置文件,并将其放在捆绑包的根目录中,与 index.html 文件放在一起。如需详细了解受支持的配置,请参阅捆绑包配置部分。 在本示例中,文件内容应该如下所示: { "instant_games": { "platform_version": "RICH_GAMEPLAY", "custom_update_templates": { "play_turn": { "example": "Edgar played their move" } } } } 通过自定义更新模板配置,我们可以为每个特定的自定义更新分配一个编号,从而更好地进行分析。您必须为所有游戏分配模板编号。 第 2 步:使用 updateAsync 发送自定义更新 在配置文件中声明模板后,便可将模板用于填充 FBInstant.updateAsync 中的必填 template 字段。以下示例说明井字棋游戏如何利用调用通知对手轮到他们出棋。您可以在右侧看到消息的展示效果。 // This will post a custom update. If the game is played in a messenger // chat thread, this will post a message into the thread with the specified // image and text message. And when people launch the game from this // message, those game sessions will be able to access the specified blob // of data through FBInstant.getEntryPointData(). FBInstant.updateAsync({ action: 'CUSTOM', cta: 'Play', image: base64Picture, text: { default: 'Edgar played their move', localizations: { en_US: 'Edgar played their move', es_LA: '\u00A1Edgar jug\u00F3 su jugada!' } } template: 'play_turn', data: { myReplayData: '...' }, strategy: 'IMMEDIATE', notification: 'NO_PUSH' }).then(function() { // closes the game after the update is posted. FBInstant.quit(); }); 有关自定义游戏环境更新的更多信息,请参阅我们的小游戏 SDK 参考文档。 如需查看相关最佳实践指南,了解何时向其他玩家发送消息、何时向他们发送通知以及最好在游戏环境更新中添加哪些内容,请参阅我们的最佳实践部分。 请注意,游戏环境更新不会发送到 Messenger 以外的地方。通过使用 context.getType() 方法和检测 THREAD 来定制游戏体验非常有用。您可以使用 context.switchAsync、context.chooseAsync 或 context.createAsync 切换到更为合适的游戏环境。 (可选)设置游戏智能助手,再次吸引玩家 小游戏的一项重要功能是能附加 Messenger 平台智能助手。这项功能虽为选择性配置,却为游戏提供了一个强有力的再参与渠道。以下指南说明了如何创建和设置游戏智能助手。 第 1 步:创建主页 如需创建游戏智能助手,您首先需要创建 Facebook 主页。主页要正确地与小游戏关联,需要具备一些特殊的属性: 主页类别需要是应用主页 主页名称需要包含应用名称。 主页不能与其他应用关联。 您可以前往"应用面板",在小游戏产品的应用主页版块创建满足这些特殊条件的主页。 在执行下一步操作前,请确保应用主页版块如右图所示:Note: if Mini Game is not correctly associated with the above type of home page, the smart assistant will not receive a messaging_game_plays event
Step 2: activate a smart assistant
After you create the home page, you need to be sure to respond to its message webhooks. Webhooks is a HTTP call we send to your backend when we send a message event to your home page. After that, the logic of your server will determine how to respond correctly to each event, if applicable. To associate the endpoint of the server with the home page event, follow the instructions in the Messenger platform Quick start tutorial to enable the smart helper for the home page. The following table describes the webhooks and permissions required to associate the Smart Assistant with Mini Game:
Partial value
Home page event
Messages and messaging_game_plays
Authority
Pages_messaging
Mini Game Smart Assistant can only use standard messages and GAME_EVENT message tags, not pages_messaging_subscriptions.
If your smart assistant has other features that need to be used for subscription messages or customer matching, you should create a separate application and reapply for Messenger platform permissions.
Step 3: respond to messaging_game_plays webhooks
After the Smart Assistant is configured correctly, your server-side application will begin to receive messaging_game_plays webhooks every time the player shuts down Mini Game. The following is an example where a server-side application detects and responds to a webhook.
If (event.game_play) {
Var senderId = event.sender.id; / / Messenger sender id
Var playerId = event.game_play.player_id; / / Instant Games player id
Var contextId = event.game_play.context_id
Var payload = event.game_play.payload
Var playerWon = payload ['playerWon']
If (playerWon) {
SendMessage (
SenderId
ContextId
'Congratulations on your victoryworthy'
'Play Again'
);
} else {
SendMessage (
SenderId
ContextId
'Better luck next timepieces'
'Rematchy'
);
}
}
You can refer to the Messenger platform documentation to learn more about webhook: the "play games" Webhook documentation.
Step 4: attract players back to the game
The following is an example of how to use the graph API to send game_play buttons to players.
Curl "https://graph.facebook.com/v2.6/me/messages?access_token="
-X POST
-H "Content-Type: application/json"
-d'{
"messaging_type": "UPDATE"
"recipient": {
"id":
}
"message": {
"attachment": {
"type": "template"
"payload": {
"template_type": "generic"
"elements": [
{
Title: "It has been a while since your last game. Time to get back"
"buttons": [
{
"type": "game_play"
"title": "Play Tic-Tac-Toe."
"payload": "{}"
"game_metadata": {
"context_id":
}
}
]
}
]
}
}
}
}'
You can refer to the Messenger platform documentation to learn more about this button: the "play Games" button documentation.
Step 5: follow our guidelines and policies
After release to the production stage, your game intelligent assistant should enter the Messenger platform submission process. Before submitting a smart assistant, be sure to follow the following best practices:
Recommendations:
Provide players with relevant, timely and valuable updates. For more information, please visit our Best practices section.
Give users control (for example, let users confirm whether they want to receive notifications and at what frequency).
Use entry point data for the play game button to load the game in an environment-dependent manner.
Give the smart assistant the same name as the game.
Take advantage of social updates such as round reminders, match results, time-limited rewards, and challenges.
Be sure to provide players with appropriate incentives to open the game through smart assistant messages. To do this, you can use the message payload to provide players with valuable in-game rewards. In general, if the smart assistant message opens the start page of the game, the message is of little value.
Use fixed menus to provide common actions, such as starting a game.
Set the default action and use game_play in custom updates so that the entire picture can bring the user into the game.
Publish new features or content through a smart assistant.
Optimize the daily message delivery time for each user, taking into account the user's time zone.
Draw on the general best practices of the Messenger Smart Assistant.
Do not:
Send a message immediately after the player closes the game.
Send a message without any background information to attract players again (for example: "get back in the game now!" ). It is recommended that you prefer messages that contain rich background information to reattract players (for example, "your scout brought you more information")
Use the tone of other Facebook users or mislead players into thinking that their friends are communicating with them.
Continue to send smart assistant messages to users who repeatedly do not want to join the game. This situation will apply policy restrictions and prevent you from sending messages. The current limit is that up to 5 messages can be sent 10 days after the end of the last game session. For more information, please refer to Section 9.4 of our Open platform Policy document
Set messaging_type to any value other than RESPONSE or UPDATE
Link to any app store.
After reading the above, do you have any further understanding of how to achieve the rapid release of Facebook Mini Game? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.