合作商服务平台

移动版QQgame大厅接入

【English ver.】(cocos)Cross-promotion plug-in

目录

1、Pre-service Configuration

Because the plug-in needs to access their own server and CDN, so you need to add security domain name to the accessing mini-games, which “request” legal domain name needs to add https://goplatform.minigame.qq.com ,while downloadFile’s domain name needs to add https://platform.minigame.qq.com (in order to download CDN images. Normally WeChat does not restrict images created through wx.createImage(), But if the underlying game download pictures via wx downloadFile ,then it is needed to add security domain name. when making joint adjustment the game sides should pay attention to that Whether the security domain has an effect on the plug-in image loading).


2、Script introduction

First, put mgplugin.js into the folder where the project holds the

script. Then, in the script of the game, introduce the module through require:

If the project uses “typescript”, the corresponding “mgplugin.d.ts” declaration file needs to be used. (in fact, cocos's “typescript” project can refer to “js” modules without declaring files, But if the project uses the typescript compilation tool or syntax checking tool, the declaration file needs to be introduced to avoid syntax error. In addition, if you use the editor of “visual studio”, it is also easy to use the declaration file to prompt code for the plug-in's interface.) The declaration file is in the code package, please refer to the usage document of typescript for the use of the declaration file.

Introduction of Typescript:


3、module call

First, you need to construct a module instance through “new”. When constructing you import the appid,and the module will pull the corresponding recommended game configuration to the background according to the appid and pull the image resources such as its icon to generate the node tree of cocos according to the appid. 

Get the root node through the root attribute of the instance:

(“获得根节点”means Get the root node

Then it is needed to insert the node into the game scene node, pay attention to ensure that the insertion of the parent node of the anchor (anchor) in the center of the game window, otherwise the plugin’s floating layer of recommended games will not be able to locate properly, the following is an example of inserting a canvas node into the game:

(“这里以游戏根节点为例,插入到游戏根节点中”means Take the game root node as an example and insert it into the game root node


The float layer node is hidden by default. When it needs to be displayed, the show method of the instance can be called. The common usage is to bind to the game's UI button click:

About the influence of upper nodes:

Since the scaling and transformation of the parent node in cocos will affect the child nodes, it is important to ensure that the upper node of the plug-in does not undergo scaling and other deformation. If the deformation of the parent node is really unavoidable, the game side should adjust the opposite deformation of the plug-in's nodes to ensure the full screen display of the UI layer of the plug-in.



4、Management of nodes

The plug-in gets the root node of the entire UI layer by accessing the root attribute of the instance, and the developer can manage the life cycle of the node independently according to the configuration of the project. But it is important to note that when the root node calls the “destroy” after destruction, if it is needed to create a node, you will need to recreate RecommendUI instance.


Matters needing attention

The rendering of the plug-in itself depends on the following components of cocos:


cc.Sprite,

cc.Mask,

cc.RichText,

cc.Label,

cc.Widget,

cc.ScrollView,

cc.Graphics,

cc.Layout,

cc.Scrollbar,

cc.BlockInputEvents


If the developer changes the source code of cocos, please note that these component parts are preserved, otherwise the plug-in will not run.

In addition, the plug-in itself relies on a small game adaptation layer built into cocos creator, such as a native XmlHttpRequest object for web requests.

It is suggested that the game side should add the switch configuration of marketing plug-in in the operation management side, so as to control whether the plug-in of external

network game is displayed at any time, so as to avoid the unexpected situation affecting the user experience.


5、 channel reporting

    In order to count game jumps achieved through cross-marketing plug-ins.The mini-games which jump in through the cross-marketing plug-in can directly invoke the interface in the plug-in for channel reporting if a marketing plug-in is also introduced. (For example : players in the game A click games in the plug-in ,and thenenter the game B by scanning QR code. If game B accesses plug-in,and the game B can call the interface of channel reporting for channel reporting when game initialization.)


When the game is initialized, it is reported through the reporting interface of the plug-in:



The parameters of the interface are: the appid of the game, the user id (as far as possible to use openid; if not, use the user id defined in the background of the game, which is mainly used to ensure the uniqueness of reporting users).



Notes:

1. The game side needs to add the plug-in switch to support the display and shielding of the version control plug-in. It needs to be closed by default before going online and opened when informed.

2. After the completion of access, you should inform us about it,for we need to do some testing. After that, it can be released online.  













回到顶部

已创建,请耐心等待审核
正在为你跳转到控制中心

关闭

创建应用

  • 1 填写应用信息
  • 2 应用审核
  • 3 确认应用合作协议
  • 4 应用推广

*以下内容均为必填项,请保证注册信息的真实性

应用类型
中文名称
英文名称
应用图标

28*28px

108*108px

* 每张图300k以内,仅支持PNG格式

游戏介绍