From 18b0c041b4aa0f4a44c40471c6b1db3b5d5d2a64 Mon Sep 17 00:00:00 2001 From: boyu0 Date: Mon, 31 Mar 2014 18:17:00 +0800 Subject: [PATCH] 1. Hide CameraTest2. 2. Correct the projection setting, fix camera center test projection. --- tests/cpp-tests/Classes/NodeTest/NodeTest.cpp | 30 +++++++++++++++---- tests/cpp-tests/Classes/NodeTest/NodeTest.h | 6 ++++ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp index b3b58bac47..5a91345e1a 100644 --- a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp +++ b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp @@ -51,7 +51,9 @@ static int sceneIdx = -1; static std::function createFunctions[] = { CL(CameraTest1), - CL(CameraTest2), + //Camera has been removed from CCNode + //todo add new feature to support it + // CL(CameraTest2), CL(CameraCenterTest), CL(Test2), CL(Test4), @@ -581,12 +583,13 @@ std::string NodeToWorld3D::subtitle() const void CameraOrbitTest::onEnter() { TestCocosNodeDemo::onEnter(); + _preProjection = Director::getInstance()->getProjection(); Director::getInstance()->setProjection(Director::Projection::_3D); } void CameraOrbitTest::onExit() { - Director::getInstance()->setProjection(Director::Projection::_2D); + Director::getInstance()->setProjection(_preProjection); TestCocosNodeDemo::onExit(); } @@ -652,13 +655,13 @@ std::string CameraOrbitTest::subtitle() const void CameraZoomTest::onEnter() { TestCocosNodeDemo::onEnter(); - + _preProjection = Director::getInstance()->getProjection(); Director::getInstance()->setProjection(Director::Projection::_3D); } void CameraZoomTest::onExit() { - Director::getInstance()->setProjection(Director::Projection::_2D); + Director::getInstance()->setProjection(_preProjection); TestCocosNodeDemo::onExit(); } @@ -717,6 +720,19 @@ std::string CameraZoomTest::subtitle() const // CameraCenterTest // //------------------------------------------------------------------ +void CameraCenterTest::onEnter() +{ + TestCocosNodeDemo::onEnter(); + _preProjection = Director::getInstance()->getProjection(); + Director::getInstance()->setProjection(Director::Projection::_3D); +} + +void CameraCenterTest::onExit() +{ + TestCocosNodeDemo::onEnter(); + Director::getInstance()->setProjection(_preProjection); +} + CameraCenterTest::CameraCenterTest() { auto s = Director::getInstance()->getWinSize(); @@ -1029,13 +1045,14 @@ void MySprite::onDraw(const kmMat4 &transform, bool transformUpdated) void CameraTest1::onEnter() { TestCocosNodeDemo::onEnter(); + _preProjection = Director::getInstance()->getProjection(); Director::getInstance()->setProjection(Director::Projection::_3D); Director::getInstance()->setDepthTest(true); } void CameraTest1::onExit() { - Director::getInstance()->setProjection(Director::Projection::_2D); + Director::getInstance()->setProjection(_preProjection); TestCocosNodeDemo::onExit(); } @@ -1075,13 +1092,14 @@ std::string CameraTest1::subtitle() const void CameraTest2::onEnter() { TestCocosNodeDemo::onEnter(); + _preProjection = Director::getInstance()->getProjection(); Director::getInstance()->setProjection(Director::Projection::_3D); Director::getInstance()->setDepthTest(true); } void CameraTest2::onExit() { - Director::getInstance()->setProjection(Director::Projection::_2D); + Director::getInstance()->setProjection(_preProjection); TestCocosNodeDemo::onExit(); } diff --git a/tests/cpp-tests/Classes/NodeTest/NodeTest.h b/tests/cpp-tests/Classes/NodeTest/NodeTest.h index 5938eb9a4f..2d92576e37 100644 --- a/tests/cpp-tests/Classes/NodeTest/NodeTest.h +++ b/tests/cpp-tests/Classes/NodeTest/NodeTest.h @@ -45,6 +45,9 @@ public: protected: TestCocosNodeDemo(); virtual ~TestCocosNodeDemo(); + +protected: + Director::Projection _preProjection; }; class Test2 : public TestCocosNodeDemo @@ -178,6 +181,9 @@ public: CREATE_FUNC(CameraCenterTest); virtual std::string title() const override; virtual std::string subtitle() const override; + + virtual void onEnter(); + virtual void onExit(); protected: CameraCenterTest();