cocos2d截图

js

var captureNode = function (node) {
    var texture = new cc.RenderTexture(display.width, display.height, null, 0x88F0);
    texture.retain();
    texture.setAnchorPoint(0, 0);
    texture.begin();
    node.visit();
    texture.end();
    var time = timestamp2time(Math.round((new Date()).valueOf() / 1000));
    time = time.replace(/[\s:-]+/g, '_');
    var nameJPG = 'ss-' + time + '.jpg';

    texture.saveToFile(nameJPG, cc.IMAGE_FORMAT_JPEG, false, function () {
        texture.release();
    });
};

 

你可能感兴趣的:(cocos2dx,cocos2d-js学习)