Cocos2d-x3.0 RenderTexture (2)

Source: Internet
Author: User


. 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 * // set the color to create parameter 1, color width 2, color height 3, color 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 );


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.