.h
#include "cocos-ext.h" #include "ui/CocosGUI.h" #include "cocostudio/CocoStudio.h" USING_NS_CC; USING_NS_CC_EXT; using namespace ui;
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);
cocos2d-x3.0 RenderTexture(二),布布扣,bubuko.com
原文:http://blog.csdn.net/qqmcy/article/details/24850451