cocos2d-x3.0 RenderTexture(2)

tags:    時間:2014-05-04 18:58:54
cocos2d-x3.0 RenderTexture(二)


.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);          


推薦閱讀文章

Bookmark the permalink ,來源:互聯網