mirror of https://github.com/axmolengine/axmol.git
Merge pull request #11947 from dabingnn/v3_bugForCameraVisitingScene
add test case to reproduce the bug for visiting scene by multiple camera
This commit is contained in:
commit
10fb660fca
|
@ -58,3 +58,66 @@ void BugChild::switchChild(Ref *sender)
|
|||
CCLOG("Child attached to parent1");
|
||||
}
|
||||
}
|
||||
|
||||
bool BugCameraMask::init()
|
||||
{
|
||||
if (!BugsTestBase::init()) return false;
|
||||
|
||||
auto size = Director::getInstance()->getWinSize();
|
||||
|
||||
auto node = Node::create();
|
||||
node->setPosition(size.width/4, size.height/3);
|
||||
_sprite = Sprite::create("Images/grossini.png");
|
||||
node->addChild(_sprite);
|
||||
node->setCameraMask((unsigned short)CameraFlag::USER1);
|
||||
auto move = MoveBy::create(2, Vec2(200,0));
|
||||
|
||||
node->runAction(RepeatForever::create(Sequence::createWithTwoActions(move, move->reverse())));
|
||||
addChild(node);
|
||||
|
||||
auto camera = Camera::create();
|
||||
camera->setCameraFlag(CameraFlag::USER1);
|
||||
addChild(camera);
|
||||
|
||||
|
||||
auto item1 = MenuItemFont::create("Switch Child", CC_CALLBACK_1(BugCameraMask::switchSpriteFlag, this));
|
||||
|
||||
auto menu = Menu::create(item1, nullptr);
|
||||
|
||||
menu->alignItemsVertically();
|
||||
menu->setPosition(size.width/2, 100);
|
||||
addChild(menu);
|
||||
|
||||
_spriteMaskLabel = Label::create();
|
||||
_spriteMaskLabel->setPosition(size.width/2, 120);
|
||||
addChild(_spriteMaskLabel);
|
||||
updateSpriteMaskLabel();
|
||||
|
||||
auto label = Label::create();
|
||||
label->setPosition(size.width/2, size.height * 0.9);
|
||||
label->setString("Sprite should always run action.");
|
||||
addChild(label);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BugCameraMask::switchSpriteFlag(Ref *sender)
|
||||
{
|
||||
if((unsigned short) CameraFlag::USER1 == _sprite->getCameraMask())
|
||||
{
|
||||
_sprite->setCameraMask((unsigned short)CameraFlag::DEFAULT);
|
||||
}
|
||||
else
|
||||
{
|
||||
_sprite->setCameraMask((unsigned short)CameraFlag::USER1);
|
||||
}
|
||||
|
||||
updateSpriteMaskLabel();
|
||||
}
|
||||
|
||||
void BugCameraMask::updateSpriteMaskLabel()
|
||||
{
|
||||
std::stringstream stream;
|
||||
stream<<"The camera Mask is "<<(_sprite->getCameraMask() == 1 ? "CamereFlag::Default" : "CameraFlag::User1")<<std::endl;
|
||||
_spriteMaskLabel->setString(stream.str());
|
||||
}
|
||||
|
|
|
@ -30,4 +30,17 @@ protected:
|
|||
cocos2d::Menu* menu;
|
||||
};
|
||||
|
||||
class BugCameraMask : public BugsTestBase
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(BugCameraMask);
|
||||
|
||||
virtual bool init() override;
|
||||
|
||||
void switchSpriteFlag(cocos2d::Ref* sender);
|
||||
void updateSpriteMaskLabel();
|
||||
Node* _sprite;
|
||||
cocos2d::Label* _spriteMaskLabel;
|
||||
};
|
||||
|
||||
#endif /* defined(__Bug_Child__) */
|
||||
|
|
|
@ -22,4 +22,5 @@ BugsTests::BugsTests()
|
|||
ADD_TEST_CASE(Bug1159Layer);
|
||||
ADD_TEST_CASE(Bug1174Layer);
|
||||
ADD_TEST_CASE(BugChild);
|
||||
ADD_TEST_CASE(BugCameraMask);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue