diff --git a/tests/cpp-tests/Classes/BillBoardTest/BillBoardTest.cpp b/tests/cpp-tests/Classes/BillBoardTest/BillBoardTest.cpp index a7462ba2c7..d33b7a6fc8 100644 --- a/tests/cpp-tests/Classes/BillBoardTest/BillBoardTest.cpp +++ b/tests/cpp-tests/Classes/BillBoardTest/BillBoardTest.cpp @@ -41,6 +41,7 @@ static int sceneIdx = -1; static std::function createFunctions[] = { + CL(BillBoardRotationTest), CL(BillBoardTest) }; @@ -72,6 +73,75 @@ static Layer* restartSpriteTestAction() return layer; } +//------------------------------------------------------------------ +// +// Billboard Rotation Test +// +//------------------------------------------------------------------ +BillBoardRotationTest::BillBoardRotationTest() +{ + auto root = Sprite3D::create(); + root->setNormalizedPosition(Vec2(.5,.25)); + addChild(root); + + auto model = Sprite3D::create("Sprite3DTest/orc.c3b"); + model->setScale(5); + model->setRotation3D(Vec3(0,180,0)); + root->addChild(model); + + auto bill = BillBoard::create(); + bill->setPosition(0, 120); + root->addChild(bill); + + auto sp = Sprite::create("Images/SpookyPeas.png"); + sp->setScale(2); + bill->addChild(sp); + + auto lbl = Label::create(); + lbl->setPosition(0, 30); + lbl->setString("+100"); + bill->addChild(lbl); + + auto r = RotateBy::create(10, Vec3(0,360,0)); + auto rp = RepeatForever::create(r); + root->runAction(rp); + + auto jump = JumpBy::create(1, Vec2(0, 0), 30, 1); + auto scale = ScaleBy::create(2, 2, 2, 0.1); + auto seq = Sequence::create(jump,scale, NULL); + + auto rot = RotateBy::create(2, Vec3(-90, 0, 0)); + auto act = Spawn::create(seq, rot,NULL); + + auto scale2 = scale->reverse(); + auto rot2 = rot->reverse(); + auto act2 = Spawn::create(scale2, rot2, NULL); + + auto seq2 = Sequence::create(act, act2, NULL); + auto repeat = RepeatForever::create(seq2); + model->runAction(repeat); +} + +BillBoardRotationTest::~BillBoardRotationTest() +{ + +} + +std::string BillBoardRotationTest::title() const +{ + return "Rotation Test"; +} + +std::string BillBoardRotationTest::subtitle() const +{ + return "All the sprites should still facing camera"; +} + +//------------------------------------------------------------------ +// +// Billboard Rendering Test +// +//------------------------------------------------------------------ BillBoardTest::BillBoardTest() : _camera(nullptr) { diff --git a/tests/cpp-tests/Classes/BillBoardTest/BillBoardTest.h b/tests/cpp-tests/Classes/BillBoardTest/BillBoardTest.h index a2203b850d..3bbf65ae28 100644 --- a/tests/cpp-tests/Classes/BillBoardTest/BillBoardTest.h +++ b/tests/cpp-tests/Classes/BillBoardTest/BillBoardTest.h @@ -34,7 +34,17 @@ namespace cocos2d { class Camera; } - +class BillBoardRotationTest : public BaseTest +{ +public: + CREATE_FUNC(BillBoardRotationTest); + BillBoardRotationTest(); + virtual ~BillBoardRotationTest(void); + virtual std::string title() const override; + virtual std::string subtitle() const override; + +protected: +}; class BillBoardTest : public BaseTest { diff --git a/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp b/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp index 54360e83aa..42d29d5969 100644 --- a/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp +++ b/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp @@ -130,6 +130,7 @@ CameraRotationTest::CameraRotationTest() auto sp3d = Sprite3D::create(); sp3d->setPosition(s.width/2, s.height/2); + sp3d->setRotation3D(Vec3(90,90,0)); addChild(sp3d); auto lship = Label::create(); @@ -140,10 +141,10 @@ CameraRotationTest::CameraRotationTest() //Billboards //Yellow is at the back bill1 = BillBoard::create("Images/Icon.png"); - bill1->setPosition3D(Vec3(s.width/2 + 50, s.height/2 + 10, -10)); + bill1->setPosition3D(Vec3(50, 10, -10)); bill1->setColor(Color3B::YELLOW); bill1->setScale(0.6f); - addChild(bill1); + sp3d->addChild(bill1); l1 = Label::create(); l1->setPosition(Vec2(0,-10)); @@ -157,9 +158,9 @@ CameraRotationTest::CameraRotationTest() bill1->addChild(p1); bill2 = BillBoard::create("Images/Icon.png"); - bill2->setPosition3D(Vec3(s.width/2 - 50, s.height/2 - 10, 10)); + bill2->setPosition3D(Vec3(-50, -10, 10)); bill2->setScale(0.6f); - addChild(bill2); + sp3d->addChild(bill2); l2 = Label::create(); l2->setString("Billboard2");