PuzzleSDK
ClippingToRenderTextureTest类 参考

#include <ClippingNodeTest.h>

+ 类 ClippingToRenderTextureTest 继承关系图:
+ ClippingToRenderTextureTest 的协作图:

Public 成员函数

 CREATE_FUNC (ClippingToRenderTextureTest)
 
void expectedBehaviour ()
 
void reproduceBug ()
 
virtual void setup () override
 
virtual std::string title () const override
 
virtual std::string subtitle () const override
 
- Public 成员函数 继承自 BaseClippingNodeTest
 CREATE_FUNC (BaseClippingNodeTest)
 
 ~BaseClippingNodeTest ()
 
virtual bool init () override
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
virtual Type getTestType () const
 
virtual float getDuration () const
 
virtual std::string getExpectedOutput () const
 
virtual std::string getActualOutput () const
 
virtual void restartTestCallback (cocos2d::Ref *sender)
 
virtual void nextTestCallback (cocos2d::Ref *sender)
 
virtual void priorTestCallback (cocos2d::Ref *sender)
 
virtual void onBackCallback (cocos2d::Ref *sender)
 
void setTestSuite (TestSuite *testSuite)
 
TestSuitegetTestSuite () const
 
float getRunTime () const
 
void setTestCaseName (const std::string &name)
 
std::string getTestCaseName () const
 
const cocos2d::Label * getSubtitleLable () const
 
const cocos2d::MenuItemImage * getRestartTestItem () const
 
virtual void onEnter () override
 

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 
- Protected 属性 继承自 TestCase
cocos2d::MenuItemImage * _priorTestItem
 
cocos2d::MenuItemImage * _restartTestItem
 
cocos2d::MenuItemImage * _nextTestItem
 
cocos2d::Label * _titleLabel
 
cocos2d::Label * _subtitleLabel
 

详细描述

在文件 ClippingNodeTest.h261 行定义.

成员函数说明

◆ CREATE_FUNC()

ClippingToRenderTextureTest::CREATE_FUNC ( ClippingToRenderTextureTest  )

◆ expectedBehaviour()

void ClippingToRenderTextureTest::expectedBehaviour ( )

在文件 ClippingNodeTest.cpp872 行定义.

873{
874 auto director = Director::getInstance();
875 Size visibleSize = director->getVisibleSize();
876 Point origin = director->getVisibleOrigin();
877
878
879 // add "HelloWorld" splash screen"
880 auto sprite = Sprite::create("Images/grossini.png");
881
882 // position the sprite on the center of the screen
883 sprite->setPosition(Point(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
884
885 // add the sprite as a child to this layer
886 this->addChild(sprite, 0);
887 sprite->setName("remove me 0");
888
889 // container node that will contain the clippingNode
890 auto container = Node::create();
891 this->addChild(container);
892 container->setName("remove me 1");
893
894 auto stencil = DrawNode::create();
895 Point triangle[3];
896 triangle[0] = Point(-50, -50);
897 triangle[1] = Point(50, -50);
898 triangle[2] = Point(0, 50);
899 Color4F green(0, 1, 0, 1);
900 stencil->drawPolygon(triangle, 3, green, 0, green);
901
902 auto clipper = ClippingNode::create();
903 clipper->setAnchorPoint(Point(0.5f, 0.5f));
904 clipper->setPosition( Point(visibleSize.width/2, visibleSize.height/2) );
905 clipper->setStencil(stencil);
906 clipper->setInverted(true);
907 container->addChild(clipper, 1);
908
909
910 auto img = DrawNode::create();
911 triangle[0] = Point(-200, -200);
912 triangle[1] = Point(200, -200);
913 triangle[2] = Point(0, 200);
914 Color4F red(1, 0, 0, 1);
915 img->drawPolygon(triangle, 3, red, 0, red);
916 clipper->addChild(img);
917}

被这些函数引用 setup().

+ 这是这个函数的调用关系图:

◆ reproduceBug()

void ClippingToRenderTextureTest::reproduceBug ( )

在文件 ClippingNodeTest.cpp919 行定义.

920{
921 auto director = Director::getInstance();
922 Size visibleSize = director->getVisibleSize();
923 Point origin = director->getVisibleOrigin();
924
925
926 // add "HelloWorld" splash screen"
927 auto sprite = Sprite::create("Images/grossini.png");
928
929 // position the sprite on the center of the screen
930 sprite->setPosition(Point(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
931
932 // add the sprite as a child to this layer
933 this->addChild(sprite, 0);
934
935
936 // container node that will contain the clippingNode
937 auto container = Node::create();
938 container->retain();
939
940 auto stencil = DrawNode::create();
941 Point triangle[3];
942 triangle[0] = Point(-50, -50);
943 triangle[1] = Point(50, -50);
944 triangle[2] = Point(0, 50);
945 Color4F green(0, 1, 0, 1);
946 stencil->drawPolygon(triangle, 3, green, 0, green);
947
948 auto clipper = ClippingNode::create();
949 clipper->setAnchorPoint(Point(0.5f, 0.5f));
950 clipper->setPosition( Point(visibleSize.width/2, visibleSize.height/2) );
951 clipper->setStencil(stencil);
952 clipper->setInverted(true);
953 container->addChild(clipper, 1);
954
955
956 auto img = DrawNode::create();
957 triangle[0] = Point(-200, -200);
958 triangle[1] = Point(200, -200);
959 triangle[2] = Point(0, 200);
960 Color4F red(1, 0, 0, 1);
961 img->drawPolygon(triangle, 3, red, 0, red);
962 clipper->addChild(img);
963
964 // container rendered on Texture the size of the screen and because Clipping node use stencil buffer so we need to
965 // create RenderTexture with depthStencil format parameter
966 RenderTexture* rt = RenderTexture::create(visibleSize.width, visibleSize.height, backend::PixelFormat::RGBA8888, PixelFormat::D24S8);
967 rt->setPosition(visibleSize.width/2, visibleSize.height/2);
968 this->addChild(rt);
969
970 rt->begin();
971 container->visit();
972 rt->end();
973}

被这些函数引用 setup().

+ 这是这个函数的调用关系图:

◆ setup()

void ClippingToRenderTextureTest::setup ( )
overridevirtual

重载 BaseClippingNodeTest .

在文件 ClippingNodeTest.cpp848 行定义.

849{
850 auto button = MenuItemFont::create("Reproduce bug", [&](Ref *sender) {
851 std::vector<Node*> nodes;
852 enumerateChildren("remove me [0-9]", [&](Node *node) {
853 nodes.push_back(node);
854 return false;
855 });
856 for (auto node : nodes)
857 {
858 this->removeChild(node);
859 }
860 this->reproduceBug();
861 });
862
863 auto s = Director::getInstance()->getWinSize();
864 // create menu, it's an autorelease object
865 auto menu = Menu::create(button, nullptr);
866 menu->setPosition(Point(s.width/2, s.height/2));
867 this->addChild(menu, 1);
868
870}

引用了 expectedBehaviour() , 以及 reproduceBug().

+ 函数调用图:

◆ subtitle()

std::string ClippingToRenderTextureTest::subtitle ( ) const
overridevirtual

重载 TestCase .

在文件 ClippingNodeTest.cpp843 行定义.

844{
845 return "Both should look the same";
846}

◆ title()

std::string ClippingToRenderTextureTest::title ( ) const
overridevirtual

重载 BaseClippingNodeTest .

在文件 ClippingNodeTest.cpp838 行定义.

839{
840 return "Clipping to RenderTexture";
841}

该类的文档由以下文件生成: