issue #4629: test case add a spriteInGroup instead of sprite, the sprite can not be seen now

This commit is contained in:
Huabing.Xu 2014-04-07 22:31:24 +08:00
parent beda294be1
commit 1b0c55ef15
1 changed files with 29 additions and 1 deletions

View File

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