Screenshot of current scene

  • olegkarman
    Likes 0

    Problem Description

    Hello.

    A few hours i’m trying to take a screenshot of my test scene, but everytime with some problem. First i’ve tried Cocos2d-js v3.10 and half of my scene was white. After that i’ve changed the engine to v3.14.1. Now there is no white sprites on my screenshot, but there are not all elements on it. Some of them are invisible.

    Have a question like this. How to take a screenshot on Cocos2d-js framework with everything on it?

     

    P.S. Here is my function to take screenshot:

    function makeScreenShot(layerToPaste, layerToVisit) {
        cc.director.setNextDeltaTimeZero(true);
        var renderTexture = new cc.RenderTexture(cc.winSize.width, cc.winSize.height);
        renderTexture.begin();
        layerToVisit.visit();
        renderTexture.end();
    
        renderTexture.setPosition(cc.winSize.width/2,cc.winSize.height/2);
        layerToPaste.addChild(renderTexture, 10000);
    }

     

  • Sonar Systems admin
    Likes 0

    When you take the screenshot, is the scene static or are things changing?

  • olegkarman
    Likes 0

    One item, that is invisible, is an animation. Also i have a few buttons that are invisible in screenshot, but they are static.

  • Sonar Systems admin
    Likes 0

    Try taking a screenshot of a simpler scene to see if that works.

  • olegkarman
    Likes 0

    I’ve tried to make screenshot on a puzzle game with no animation on it. As far as i understand, if the scene is completely static, Cocos will make correct screenshot, but with the animation the problems begins to occur.

  • olegkarman
    Likes 0

    Ok, i will try. Thank you!

     

    I see that this video is how to get screenshot on native platforms. But how about html5?


  • Sonar Systems admin
    Likes 0

    Its for Cocos2d-x, you should be able to adapt the methods.

Login to reply