mirror of https://github.com/axmolengine/axmol.git
issue #4629: test case add a spriteInGroup instead of sprite, the sprite can not be seen now
This commit is contained in:
parent
beda294be1
commit
1b0c55ef15
|
@ -223,9 +223,37 @@ std::string NewSpriteTest::subtitle() const
|
||||||
return "SpriteTest";
|
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()
|
GroupCommandTest::GroupCommandTest()
|
||||||
{
|
{
|
||||||
auto sprite = Sprite::create("Images/grossini.png");
|
auto sprite = SpriteInGroupCommand::create("Images/grossini.png");
|
||||||
Size winSize = Director::getInstance()->getWinSize();
|
Size winSize = Director::getInstance()->getWinSize();
|
||||||
sprite->setPosition(winSize.width/2,winSize.height/2);
|
sprite->setPosition(winSize.width/2,winSize.height/2);
|
||||||
addChild(sprite);
|
addChild(sprite);
|
||||||
|
|
Loading…
Reference in New Issue