From cc18a3a95552f934ffe24da3eb3beff2d1e8c672 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Mon, 26 Jan 2015 18:44:30 +0800 Subject: [PATCH] another use case not finished --- .../Classes/Sprite3DTest/Sprite3DTest.cpp | 33 +++++++++++-------- .../Classes/Sprite3DTest/Sprite3DTest.h | 1 + 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp index a6b23ed9c6..3c43eaa864 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp @@ -2115,13 +2115,13 @@ UseCaseSprite3D::UseCaseSprite3D() auto s = Director::getInstance()->getWinSize(); _useCaseTitles[0] = "transparent 3d sprite and 2d sprite"; - + _useCaseTitles[1] = "ui - 3d - ui"; auto itemPrev = MenuItemImage::create("Images/b1.png", "Images/b2.png", [&](Ref *sender) { _caseIdx--; if (_caseIdx < 0) - _caseIdx = 0; + _caseIdx = (int)USECASE::MAX_CASE_NUM - 1; this->switchCase(); }); @@ -2129,7 +2129,7 @@ UseCaseSprite3D::UseCaseSprite3D() [&](Ref *sender) { _caseIdx++; if (_caseIdx >= (int)USECASE::MAX_CASE_NUM) - _caseIdx = (int)USECASE::MAX_CASE_NUM - 1; + _caseIdx = 0; this->switchCase(); }); @@ -2213,6 +2213,10 @@ void UseCaseSprite3D::switchCase() _sprite3d->setCameraMask(2); _sprite2d->setCameraMask(2); } + else if (_caseIdx == 1) + { + + } scheduleUpdate(); update(0.f); @@ -2220,14 +2224,17 @@ void UseCaseSprite3D::switchCase() void UseCaseSprite3D::update(float delta) { - static float accAngle = 0.f; - accAngle += delta * CC_DEGREES_TO_RADIANS(60); - - float radius = 30.f; - float x = cosf(accAngle) * radius, z = sinf(accAngle) * radius; - - _sprite3d->setPositionX(x); - _sprite3d->setPositionZ(z); - _sprite2d->setPositionX(x); - _sprite2d->setPositionZ(z); + if (_caseIdx == 0) + { + static float accAngle = 0.f; + accAngle += delta * CC_DEGREES_TO_RADIANS(60); + + float radius = 30.f; + float x = cosf(accAngle) * radius, z = sinf(accAngle) * radius; + + _sprite3d->setPositionX(x); + _sprite3d->setPositionZ(z); + _sprite2d->setPositionX(x); + _sprite2d->setPositionZ(z); + } } diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h index 13aaed415d..330303d331 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h @@ -471,6 +471,7 @@ protected: enum class USECASE{ _3D_WITH_2D, + _UI_3D_UI, MAX_CASE_NUM, }; cocos2d::Label* _label;