From 1b0c55ef15588b1b0012fd10f560bee7ff9cf5c2 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 7 Apr 2014 22:31:24 +0800 Subject: [PATCH] issue #4629: test case add a spriteInGroup instead of sprite, the sprite can not be seen now --- .../NewRendererTest/NewRendererTest.cpp | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/tests/cpp-tests/Classes/NewRendererTest/NewRendererTest.cpp b/tests/cpp-tests/Classes/NewRendererTest/NewRendererTest.cpp index 38fbb7cecb..a7a72db35d 100644 --- a/tests/cpp-tests/Classes/NewRendererTest/NewRendererTest.cpp +++ b/tests/cpp-tests/Classes/NewRendererTest/NewRendererTest.cpp @@ -223,9 +223,37 @@ std::string NewSpriteTest::subtitle() const return "SpriteTest"; } +class SpriteInGroupCommand : public Sprite +{ +protected: + GroupCommand _spriteWrapperCommand; +public: + static SpriteInGroupCommand* create(const std::string& filename); + + virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override; +}; + +SpriteInGroupCommand* SpriteInGroupCommand::create(const std::string &filename) +{ + SpriteInGroupCommand* sprite = new SpriteInGroupCommand(); + sprite->initWithFile(filename); + sprite->autorelease(); + return sprite; +} + +void SpriteInGroupCommand::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) +{ + CCASSERT(renderer, "Render is null"); + _spriteWrapperCommand.init(_globalZOrder); + renderer->addCommand(&_spriteWrapperCommand); + renderer->pushGroup(_spriteWrapperCommand.getRenderQueueID()); + Sprite::draw(renderer, transform, transformUpdated); + renderer->popGroup(); +} + GroupCommandTest::GroupCommandTest() { - auto sprite = Sprite::create("Images/grossini.png"); + auto sprite = SpriteInGroupCommand::create("Images/grossini.png"); Size winSize = Director::getInstance()->getWinSize(); sprite->setPosition(winSize.width/2,winSize.height/2); addChild(sprite);