首页 > 其他 > 详细

cocos2d-x3.0 RenderTexture(二)

时间:2014-05-02 21:28:27      阅读:821      评论:0      收藏:0      [点我收藏+]


.h

#include "cocos-ext.h"
#include "ui/CocosGUI.h"
#include "cocostudio/CocoStudio.h"
USING_NS_CC;

USING_NS_CC_EXT;
using namespace ui;

.cpp

   auto background = LayerColor::create(Color4B(200,200,200,255));
        addChild(background);
        
        
        auto s = Director::getInstance()->getWinSize();
        auto spr_premulti = Sprite::create("fire.png");
        spr_premulti->setPosition(Point(s.width/2-16, s.height/2+36));
        
        
        
        
        
        
        auto spr_nonpremulti = Sprite::create("fire.png");
        spr_nonpremulti->setPosition(Point(s.width/2-16, s.height/2-16));
//
//        /* A2 & B2 setup */
        //着色文理     create参数1、着色的宽 2、着色的高  3、颜色
        auto rend = RenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA8888);
        
        auto spr_size = spr_premulti->getContentSize();
        rend->setKeepMatrix(true);
        Size pixelSize = Director::getInstance()->getWinSizeInPixels();
        
        rend->setVirtualViewport(Point(0, 0), Rect(0, 0, s.width, s.height), Rect(0, 0, pixelSize.width, pixelSize.height));
        
        
        // It‘s possible to modify the RenderTexture blending function by
        //        [[rend sprite] setBlendFunc:(BlendFunc) {GL_ONE, GL_ONE_MINUS_SRC_ALPHA}];

        rend->begin();
        
        spr_premulti->visit();
        spr_nonpremulti->visit();
        rend->end();
        rend->setPosition(Point(s.width / 2 + 56, s.height / 2));
       
        addChild(spr_premulti);
        addChild(spr_nonpremulti);
       
        addChild(rend);
        
bubuko.com,布布扣

cocos2d-x3.0 RenderTexture(二),布布扣,bubuko.com

cocos2d-x3.0 RenderTexture(二)

原文:http://blog.csdn.net/qqmcy/article/details/24850451

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!