
import { _decorator, Component, Node, sys, systemEvent } from 'cc';
import { Util } from './util';
const { ccclass, property } = _decorator;

// 原生交互
export class Native {
    
    static callFunc(funcName:string, n:string, n2:string){
        Util.log('测试调用:isNative = '+sys.isNative+'  isMobile='+sys.isMobile);
        if(sys.isNative){
            // android
            if(sys.os == sys.OS_ANDROID){
                Util.log('调用android接口:' + funcName);
                let ojb = jsb.reflection.callStaticMethod('com/cocos/game/test', funcName, "(Ljava/lang/String;Ljava/lang/String;)V", n, n2);
            }
            else if(sys.os == sys.OS_IOS){

            }
        }
    }

    static callback(ret:string){
        Util.log('原生系统回调:' +ret);
        systemEvent.emit("showMsg", ret, 2);
    }
}
declare global {
    interface Window {
        Native: any
    }
  }
window.Native = Native;
