creator 위챗 캡처 공유

1414 단어
shareScreenShot:function(event,CustomEventData){
    //  
    var canvas = cc.director.getScene().getChildByName('Canvas');
    var renderTexture = cc.RenderTexture.create(1136,640, cc.Texture2D.PIXEL_FORMAT_RGBA8888, gl.DEPTH24_STENCIL8_OES);
    canvas._sgNode.addChild(renderTexture);
    renderTexture.setVisible(false);
    // var renderTexture = cc.RenderTexture.create(1136,640);
    renderTexture.begin();
    canvas._sgNode.visit();
    // this.pnlFinal.getChildByName("resultPanel")._sgNode.visit();
    renderTexture.end();
    var that = this;
    renderTexture.saveToFile("screenShot.png",cc.ImageFormat.PNG,true,function(){
        renderTexture.removeFromParent();
        console.log(" ");
        var scene = CustomEventData - 0;   
    var imgUrl = jsb.fileUtils.getWritablePath() + "screenShot.png";
    if(cc.sys.os == cc.sys.OS_IOS){
        // ios 
        jsb.reflection.callStaticMethod("WXApiManager","shareScreenshotWithScene:andImgUrl:",scene,imgUrl);
    }else if(cc.sys.os == cc.sys.OS_ANDROID){
        //  
        var ret = jsb.reflection.callStaticMethod(
            "org/cocos2dx/javascript/AppActivity",
            "shareScreenShot",
            "(Ljava/lang/String;Ljava/lang/String;)V",
            CustomEventData,
            imgUrl
        );
    }
    });

    


},

좋은 웹페이지 즐겨찾기