第一节 API


一、游戏分析API

       游戏关卡的统计(开始):this.hs_gameEngine.reportingData("LevelBegin", String levelId);
       游戏关卡的统计(完成):this.hs_gameEngine.reportingData("LevelComplete", String levelId);
       游戏关卡的统计(失败):this.hs_gameEngine.reportingData("LevelFail", String levelId, String reason);
       使用须知:在游戏开启新的关卡的时候调用LevelBegin方法.关卡顺利通过需要调用LevelComplete方法,任务通关失败需要调用LevelFail.其中LevelBegin和LevelComplete/LevelFail方法需要配对出现,即开始-结束,开始-结束;不可以开始开始,结束结束这样调用. 关卡与任务的不同之处在于,同一时间只能执行一个关卡,而同一时间并行的可以执行多个任务.这也就决定了LevelBegin和LevelComplete/LevelFail方法需要线性的配对出现,而TaskBegin和LevelComplete/TaskFail可以嵌套出现. LevelBegin方法和LevelComplete/LevelFail方法是相互对应的,开始结束方法levelId必须保持一致。
关卡相关的指标中有个关卡失败率的统计,实际数据中会出现关卡失败率比较高的情况,甚至异常的情况. 请接入的同学重点关注下下面可能的几个原因: 原因1:调用DCLevels.begin接口,但是没有调用LevelFail/LevelComplete接口,导致任务只有开始没有结束,无法正常的进行结算. 原因2:调用DCLevels.begin接口也调用了LevelFail/LevelComplete但是两个接口的levelId参数对应不上.这样系统处理的时候也是只认为有开始没有结束,导致指标计算处理的值异常 原因3:进入关卡的时候调用了DCLevels.begin,同学们在关卡的完成时也调用了LevelFail/LevelComplete.但是关卡进行中用户主动退出关卡的情况,有同学不调用LevelFail接口.导致指标计算有偏差. 如果玩家开启关卡后,没有完成关卡就退出了关卡,建议调用fail接口,原因可填写为玩家退出,这样关卡相关信息统计更准确
//示例: 比如某塔防游戏的第11关,僵尸来袭.统计这个关卡的相关信息,需要进行如下调用.
//关卡开始
this.hs_gameEngine.reportingData("LevelBegin", "僵尸来袭");
//玩家通过该关卡,则调用complete
this.hs_gameEngine.reportingData("LevelComplete", "僵尸来袭");
//玩家在该关卡通关失败,则调用fail
this.hs_gameEngine.reportingData("LevelFail", "僵尸来袭", "城堡失守");

       游戏任务的统计(开始):this.hs_gameEngine.reportingData("TaskBegin", String taskId, int type); // type:0.新手任务 1.主线任务 2.分支任务 3.日常任务 4.活动任务 5.其他任务
       游戏任务的统计(完成):this.hs_gameEngine.reportingData("TaskComplete", String taskId);
       游戏任务的统计(失败):this.hs_gameEngine.reportingData("TaskFail", String taskId, String reason);
//示例1:如果在主线任务"解救公主"的执行过程中,开发者可以如下形式调用
//解救公主任务开始
this.hs_gameEngine.reportingData("TaskBegin", "help_priness", 1);
//解救公主任务结束
this.hs_gameEngine.reportingData("TaskFail", "help_priness","任务超时"); //任务失败
//示例2:如果在"解救公主"的主线任务中还有一个"获取钥匙"的支线任务,开发者可以如下形式调用
//解救公主任务开始
this.hs_gameEngine.reportingData("TaskBegin", "help_priness", 1);
// …
//获取钥匙任务开始
this.hs_gameEngine.reportingData("TaskBegin", "get_key", 2);
//获取钥匙任务结束
this.hs_gameEngine.reportingData("TaskComplete", "get_key"); //任务成功
//…
//解救公主任务结束
this.hs_gameEngine.reportingData("TaskFail", "help_priness","生命耗尽"); //任务失败

       道具购买:this.hs_gameEngine.reportingData("ItemBuy", String itemId, String itemType, int itemCnt,int vituralCurrency,String currencyType,String consumePoint, String levelId);
       //道具编号,道具类型,购买的道具数量,购买道具消耗的虚拟币数量,虚拟币类型,付费点,建议使用关卡或者任务标识,或者记录付费场景,当前玩家所在关卡
       道具获得:this.hs_gameEngine.reportingData("ItemGet", String itemId, String itemType, int itemCnt,String reason, String levelId);//道具编号,道具类型,获得的道具数量,获得道具的原因,当前玩家所在关卡
       道具消耗:this.hs_gameEngine.reportingData("ItemConsume", String itemId, String itemType, int itemCnt,String reason,String levelId);//道具编号,道具类型,消耗的道具数量,消耗道具的原因,当前玩家所在关卡
       获取虚拟币:this.hs_gameEngine.reportingData("CoinGain", String reason, String coinType, long gain,long left, String levelId);//获取金币原因,虚拟币类型,玩家获取的虚拟币数量(请不要传入负值),玩家加上获取后的虚拟币数量,当前所在关卡
       消耗虚拟币:this.hs_gameEngine.reportingData("CoinLost", String reason, String coinType, long lost,long left, String levelId);//消耗金币原因,虚拟币类型,玩家消耗的虚拟币数量(请不要传入负值),玩家减去消耗后的虚拟币数量,当前所在关卡
       真实付费:this.hs_gameEngine.reportingData("Pay", String orderId,String iapId, double currencyAmount,String currencyType ,String paymentType, String levelId);//支付流水号,礼包编号,付费现金,货币代码(人民币CNY,美元USD等),支付途径(如"xxx支付SDK","支付宝"),当前所在关卡
       自定义事件:this.hs_gameEngine.reportingData(String eventId,String label);//this.hs_gameEngine.reportingData("touch_share_btn","WeChat");



回到顶部
返回目录