Share screenshot FB & Twitter ?

  • soulmasterbn
    Likes 0

    Problem Description

    I want share screenshot with fb & twitter 

    my code : 

     

    void Main::captureScreenshot()

    {

        

        Size screen = Director::getInstance()->getWinSize();

        RenderTexture *texture = RenderTexture::create(screen.width, screen.height);

        texture->setPosition(screen.width / 2, screen.height / 2);

        

        texture->begin();

        Director::getInstance()->getRunningScene()->visit();

        texture->end();

        texture->saveToFile("screenshot.png", Image::Format::PNG);

        

        

    }

     

    void Main::ShareTW(){

        

        captureScreenshot();

        

        CallFunc *call = CallFunc::create([=]{

             SonarCocosHelper::Twitter::Tweet("Best Game In The AppStore ", "Reverse Rush", "screenshot.png");

        });

        

        runAction(Sequence::create(DelayTime::create(0.5f), call, NULL));

        

       

    }

     

     

    I can’t find “screenshot.png” path . please help !

    Solution Description

    I want share screenshot with fb & twitter 

    my code : 

     

    void Main::captureScreenshot()

    {

        

        Size screen = Director::getInstance()->getWinSize();

        RenderTexture *texture = RenderTexture::create(screen.width, screen.height);

        texture->setPosition(screen.width / 2, screen.height / 2);

        

        texture->begin();

        Director::getInstance()->getRunningScene()->visit();

        texture->end();

        texture->saveToFile("screenshot.png"Image::Format::PNG);

        

        

    }

     

    void Main::ShareTW(){

        

        captureScreenshot();

        

        CallFunc *call = CallFunc::create([=]{

             SonarCocosHelper::Twitter::Tweet("Best Game In The AppStore ""Reverse Rush""screenshot.png");

        });

        

        runAction(Sequence::create(DelayTime::create(0.5f), call, NULL));

        

       

    }

     

     

    I can’t find “screenshot.png” path . please help !

  • Sonar Systems admin
    Likes 1

    Is this a question?

  • soulmasterbn
    Likes 0

    Sure, You can help me share FB & Twitter  with image screenshot ? (not image in resources folder ) thank smiley

  • Sonar Systems admin
    Likes 1

    Try using the after capture method.

  • soulmasterbn
    Likes 0

    I tried but I can’t see Screenshot in popup share : 


  • Sonar Systems admin
    Likes 1

    Try displaying that image in a sprite to see if that is working.

  • soulmasterbn
    Likes 0

    OH yes, I can see when display this to sprite, but share method can’t not find  this path ? 

  • Sonar Systems admin
    Likes 1

    ??????????  

  • soulmasterbn
    Likes 0

    I create sprite with path image from “captureScreen” method success

    But when I use this path for “SonarHelper Share method” not work :( ( fail )

  • Sonar Systems admin
    Likes 1

    Try with a local image ot see if that works.

Login to reply