mirror of https://github.com/axmolengine/axmol.git
Create rotation test case for billboard
This commit is contained in:
parent
bec21d8e7f
commit
414115690e
|
@ -41,6 +41,7 @@ static int sceneIdx = -1;
|
|||
|
||||
static std::function<Layer*()> createFunctions[] =
|
||||
{
|
||||
CL(BillBoardRotationTest),
|
||||
CL(BillBoardTest)
|
||||
};
|
||||
|
||||
|
@ -72,6 +73,71 @@ 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 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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue