cocos: RenderTexture 合并精灵图片

var render = new cc.RenderTexture(730, 450); //创建渲染纹理对象,并数字确定宽度
    render.begin();

    var sp1 = cc.Sprite.create("xxx.png");
    sp1.setAnchorPoint(0, 0);
    sp1.setPosition(0, 0);
    sp1.visit();

    var sp2 = cc.Sprite.create("xxx2.png");
    sp2.setAnchorPoint(1, 1);
    sp2.setPosition(730, 450);
    sp2.visit();
    render.end();

   var spriteFrame = render.getSprite().getSpriteFrame();

 spCard.setSpriteFrame(spriteFrame);
 spCard.setFlippedY(true); //因为生成的图片 Y 方向颠倒,所以翻转

参考:

http://forum.cocos.com/t/creator/40750
https://www.jianshu.com/p/83864361870c

posted on 2018-03-08 14:21  ZhYQ_note  阅读(...)  评论(...编辑  收藏

导航