Merge pull request #10245 from darkdukey/fixCameraTest

Fix BillboardTest
This commit is contained in:
Nite Luo 2015-01-27 14:31:17 -08:00
commit 4211b8d07d
2 changed files with 63 additions and 4 deletions

View File

@ -47,7 +47,7 @@ static std::function<Layer*()> createFunctions[] =
#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0]))
static Layer* nextSpriteTestAction()
static Layer* nextTest()
{
sceneIdx++;
sceneIdx = sceneIdx % MAX_LAYER;
@ -56,7 +56,7 @@ static Layer* nextSpriteTestAction()
return layer;
}
static Layer* backSpriteTestAction()
static Layer* backTest()
{
sceneIdx--;
int total = MAX_LAYER;
@ -67,7 +67,7 @@ static Layer* backSpriteTestAction()
return layer;
}
static Layer* restartSpriteTestAction()
static Layer* restartTest()
{
auto layer = (createFunctions[sceneIdx])();
return layer;
@ -137,6 +137,31 @@ std::string BillBoardRotationTest::subtitle() const
return "All the sprites should still facing camera";
}
void BillBoardRotationTest::restartCallback(Ref* sender)
{
auto s = new (std::nothrow) BillBoardTestScene();
s->addChild(restartTest());
Director::getInstance()->replaceScene(s);
s->release();
}
void BillBoardRotationTest::nextCallback(Ref* sender)
{
auto s = new (std::nothrow) BillBoardTestScene();
s->addChild(nextTest());
Director::getInstance()->replaceScene(s);
s->release();
}
void BillBoardRotationTest::backCallback(Ref* sender)
{
auto s = new (std::nothrow) BillBoardTestScene();
s->addChild(backTest());
Director::getInstance()->replaceScene(s);
s->release();
}
//------------------------------------------------------------------
//
// Billboard Rendering Test
@ -338,9 +363,35 @@ void BillBoardTest::rotateCameraCallback(Ref* sender,float value)
_camera->setRotation3D(rotation3D);
}
void BillBoardTest::restartCallback(Ref* sender)
{
auto s = new (std::nothrow) BillBoardTestScene();
s->addChild(restartTest());
Director::getInstance()->replaceScene(s);
s->release();
}
void BillBoardTest::nextCallback(Ref* sender)
{
auto s = new (std::nothrow) BillBoardTestScene();
s->addChild(nextTest());
Director::getInstance()->replaceScene(s);
s->release();
}
void BillBoardTest::backCallback(Ref* sender)
{
auto s = new (std::nothrow) BillBoardTestScene();
s->addChild(backTest());
Director::getInstance()->replaceScene(s);
s->release();
}
void BillBoardTestScene::runThisTest()
{
auto layer = nextSpriteTestAction();
auto layer = nextTest();
addChild(layer);
Director::getInstance()->replaceScene(this);
}

View File

@ -43,6 +43,10 @@ public:
virtual std::string title() const override;
virtual std::string subtitle() const override;
virtual void restartCallback(Ref* sender) override;
virtual void nextCallback(Ref* sender) override;
virtual void backCallback(Ref* sender) override;
protected:
};
@ -63,6 +67,10 @@ public:
void menuCallback_orientedPoint(Ref* sender);
void menuCallback_orientedPlane(Ref* sender);
virtual void restartCallback(Ref* sender) override;
virtual void nextCallback(Ref* sender) override;
virtual void backCallback(Ref* sender) override;
protected:
Camera* _camera;
Layer* _layerBillBorad;