future 1 жил өмнө
parent
commit
f2a9d68596

+ 2 - 2
assets/scene/game.scene

@@ -9590,7 +9590,7 @@
       "__id__": 265
     },
     "_children": [],
-    "_active": false,
+    "_active": true,
     "_components": [
       {
         "__id__": 271
@@ -10085,7 +10085,7 @@
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 1080,
-      "height": 1920.0000000000002
+      "height": 1920
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",

+ 2 - 0
assets/script/config.ts

@@ -4,6 +4,7 @@ const { ccclass, property } = _decorator;
 
 export class config {
     static debug = false;
+    static gameName = "神秘的笔记";
     static select_res_and_control_type = {
         RES_TYPE:0,
         CONTROL_TYPE:1,
@@ -293,6 +294,7 @@ export class config {
     }
     static TOKEN:string = ""
     static USER_DATA:string = "userData"
+    static TT_SHARE_TEMPLATEID:String = "i6e10hgb28e41bj68g"
     static TT_REWARD ={
         RE_LIFE: "122kafg9cd5f187ib3",
         ANSWER: "j6abe2594e84399f4k",

+ 1 - 9
assets/script/run/gameManager.ts

@@ -312,15 +312,9 @@ export class gameManager extends Component {
     }
 
     public gotoGameLevel() {
-        console.log('进入游戏关卡 进入游戏关卡')
         SdkUtil.ttStartScreenRecording()
     }
 
-    public gameLevelSuccessBackGameList() {
-        console.log('游戏关卡成功返回游戏列表 游戏关卡成功返回游戏列表 游戏关卡成功返回游戏列表')
-        gameManager.Singleton.backGameList()
-    }
-
     public backGameList(){
         if(!gameManager.isLoadingStatus){
             this.unscheduleAllCallbacks()
@@ -330,9 +324,7 @@ export class gameManager extends Component {
             console.log("没有全部加载完成!")
         }
 
-        SdkUtil.ttStopScreenRecording()
-        // let videoPath = SdkUtil.ttGetScreenRecordingVideoPath()
-        // console.log('录制视频的路径=',videoPath)
+        SdkUtil.ttStopScreenRecording(true)
     }
 
     public initEvent(){

+ 7 - 1
assets/script/run/top_layer.ts

@@ -11,6 +11,7 @@ import { rule_view } from './tips/rule_view';
 import { tips_view } from './tips/tips_view';
 import { fail } from './ui/fail';
 import { win } from './ui/win';
+import { SdkUtil } from '../sdkUtil';
 const { ccclass, property } = _decorator;
 
 @ccclass('top_layer')
@@ -106,11 +107,16 @@ export class top_layer extends Component {
             this.mIsShowWin = true
             let level_data = gameManager.Singleton.getLevelData()
             ClientEvent.dispatchEvent(config.EventRun.WIN_LATER_AUTO_UNLOCK_NEXT_LEVEL,level_data)
+
+            setTimeout(()=> {
+                SdkUtil.ttStopScreenRecording()
+            },1500)
         }
     }
 
     onClickShare(){
-
+        let videoPath = SdkUtil.ttGetScreenRecordingVideoPath()
+        SdkUtil.shareGame(config.gameName, '', videoPath)
     }
 
     onClickNext(){

+ 1 - 1
assets/script/run/ui/win.ts

@@ -31,7 +31,7 @@ export class win extends Component {
         })
         this.btn_close.on(Node.EventType.TOUCH_END,()=>{
             this.node.active = false;
-            gameManager.Singleton.gameLevelSuccessBackGameList()
+            gameManager.Singleton.backGameList()
             this.icon.getComponent(Sprite).spriteFrame = null
         })
 

+ 67 - 61
assets/script/sdkUtil.ts

@@ -1,5 +1,6 @@
 import { _decorator, SpriteFrame, sys } from "cc";
 import { gameManager } from "./run/gameManager";
+import { config } from "./config";
 //管理广告、分享、SDK相关内容的组件
 export class SdkUtil {
     public static platform: string = 'cocos'; //平台
@@ -22,10 +23,10 @@ export class SdkUtil {
     public static tt_isSupportSidebar:boolean = false;   //抖音_是否支持侧边栏
     public static tt_isToEnterFromSidebar:boolean = false; //抖音_是否从侧边栏进入
 
-    private static ttGameRecorder:any = null;      //抖音游戏录制
-    private static ttRecordVideoPath:string = '';  //抖音录制视频路径
-    private static ttTotalRecord:number = 300;     //抖音总录制时间
-    private static ttIsRecording:boolean = false;  //抖音是否录制中
+    private static tt_gameRecorder:any = null;      //抖音游戏录制
+    private static tt_recordVideoPath:string = '';  //抖音录制视频路径
+    private static tt_totalRecord:number = 300;     //抖音总录制时间
+    private static tt_isRecording:boolean = false;  //抖音是否录制中
 
     /**
        * 自定义事件统计
@@ -59,50 +60,58 @@ export class SdkUtil {
 
 
     /**
-     * 微信分享
+     * 抖音/微信分享
      * 
      * @static
      * @param {string} title
      * @param {string} imageUrl
+     * @param {string} videoPath
      * @returns
      * @memberof SdkUtil
      */
-    public static shareGame(title: string, imageUrl: string) {
-        //@ts-ignore
-        if (!window.wx) {
-            return;
+    public static shareGame(title: string, imageUrl: string, videoPath: string) {
+        if(sys.platform == sys.Platform.BYTEDANCE_MINI_GAME) {
+            if(videoPath!="") {
+                this.ttShareScreenRecordVideo(title,videoPath)
+            }
+        } else if(sys.platform == sys.Platform.WECHAT_GAME) {
+            // 微信分享
         }
+        // //@ts-ignore
+        // if (!window.wx) {
+        //     return;
+        // }
 
-        //@ts-ignore
-        wx.showShareMenu({
-            withShareTicket: true,
-            complete: () => {
+        // //@ts-ignore
+        // wx.showShareMenu({
+        //     withShareTicket: true,
+        //     complete: () => {
 
-            }
-        });
+        //     }
+        // });
 
-        //@ts-ignore
-        if (wx.aldOnShareAppMessage) {
-            //@ts-ignore
-            wx.aldOnShareAppMessage(function () {
-                // 用户点击了“转发”按钮
-                return {
-                    title: title,
-                    imageUrl: imageUrl,
+        // //@ts-ignore
+        // if (wx.aldOnShareAppMessage) {
+        //     //@ts-ignore
+        //     wx.aldOnShareAppMessage(function () {
+        //         // 用户点击了“转发”按钮
+        //         return {
+        //             title: title,
+        //             imageUrl: imageUrl,
 
-                };
-            });
-        } else {
-            //@ts-ignore
-            wx.onShareAppMessage(function () {
-                // 用户点击了“转发”按钮
-                return {
-                    title: title,
-                    imageUrl: imageUrl,
+        //         };
+        //     });
+        // } else {
+        //     //@ts-ignore
+        //     wx.onShareAppMessage(function () {
+        //         // 用户点击了“转发”按钮
+        //         return {
+        //             title: title,
+        //             imageUrl: imageUrl,
 
-                };
-            });
-        }
+        //         };
+        //     });
+        // }
     }
 
     
@@ -221,7 +230,6 @@ export class SdkUtil {
 
     // 抖音开启屏幕录制
     public static ttStartScreenRecording() {
-        return
         if(sys.platform!=sys.Platform.BYTEDANCE_MINI_GAME) {
             return
         }
@@ -230,57 +238,60 @@ export class SdkUtil {
             this.ttStopScreenRecording()
         }
         
-        this.ttIsRecording = true
-        if(!this.ttGameRecorder) {
-            this.ttGameRecorder = tt.getGameRecorderManager()
+        if(!this.tt_gameRecorder) {
+            this.tt_gameRecorder = tt.getGameRecorderManager()
         }
-        this.ttGameRecorder.start({duration: this.ttTotalRecord})
-        this.ttGameRecorder.onStart(()=> {
+        this.tt_gameRecorder.start({duration: this.tt_totalRecord})
+        this.tt_gameRecorder.onStart(()=> {
+            this.tt_isRecording = true
             console.log('GameRecorder onStart onStart onStart')
         })
-        this.ttGameRecorder.onStop((res)=> {
+        this.tt_gameRecorder.onStop((res)=> {
             console.log('GameRecorder onStop onStop onStop=',res)
-            this.ttIsRecording = false
-            this.ttRecordVideoPath = res.videoPath
-            SdkUtil.ttShareScreenRecordVideo('测试测试',res.videoPath)
+            this.tt_isRecording = false
+            this.tt_recordVideoPath = res.videoPath
         })
-        this.ttGameRecorder.onError((e)=> {
+        this.tt_gameRecorder.onError((e)=> {
             console.log('ttGameRecord error:',e)
         })
     }
 
     // 抖音关闭屏幕录制
-    public static ttStopScreenRecording() {
-        return
+    public static ttStopScreenRecording(isClearVideoPath:boolean = false) {
         if(sys.platform!=sys.Platform.BYTEDANCE_MINI_GAME) {
             return
         }
 
-        if(this.ttGameRecorder == null) {
+        if(this.tt_gameRecorder == null) {
             return
         }
+
+        if(isClearVideoPath) {
+            this.tt_recordVideoPath = "";
+        }
         
-        this.ttGameRecorder.stop()        
+        this.tt_gameRecorder.stop()        
     }
 
     // 抖音是否屏幕录制
     public static ttIsScreenRecording():boolean {
-        return this.ttIsRecording;
+        return this.tt_isRecording;
     }
 
     // 抖音获取屏幕录制视频文件
     public static ttGetScreenRecordingVideoPath():string {
-        return this.ttRecordVideoPath;
+        return this.tt_recordVideoPath;
     }
 
     // 抖音分享屏幕录制视频
-    public static ttShareScreenRecordVideo(title: string, videoPath: string, onSuccess: Function = null, onFail: Function = null) {
+    private static ttShareScreenRecordVideo(title: string, videoPath: string, onSuccess: Function = null, onFail: Function = null) {
         tt.shareAppMessage({
             title: title,
+            templateId: config.TT_SHARE_TEMPLATEID,
             channel: "video",
             extra: {
-                videoTopics: [],
-                hashtag_list: [],
+                videoTopics: [config.gameName],
+                hashtag_list: ['小游戏','小程序'],
                 videoPath: videoPath,
                 withVideoId: true,
             },
@@ -289,13 +300,8 @@ export class SdkUtil {
                 onSuccess && onSuccess();
             },
             fail: (e) => {
-                console.log('抖音分享屏幕录制视频,失败=',e)
-                // if(this.checkAppName()){
-                //     onSuccess && onSuccess();
-                // }else{
-                //     onFail && onFail();
-                // }
                 // 当前今日头条ios无法获得分享成功回调 if(res.platform === 'ios' && res.appName === 'Toutiao')
+                console.log('抖音分享屏幕录制视频,失败=',e)
                 onFail && onFail()
             }
         })