标签:
BillBoard的使用
auto root = Sprite3D::create();
root ->setNormalizedPosition(Vec2(.5,.25));
addChild(root);
BillBoard / Spawn / Sequence 的使用
auto mode1 = Sprite3D::create("Sprite3DTest/orc.c3b");
mode1->setScale(5);
mode1->setRotation3D(Vec3(0,180,0));
root->addChild(mode1);
auto bill = BillBoard::create();//BillBoard 广告牌
bill->setPosition(0,120);
root->addChild(bill);
auto sp = Sprite::create("Images/SpookyPeas.png");
sp->setScale(2);
bill->addChild(sp);
auto lb1 = Label::create();
lb1->setPosition(0,30);
lb1->setString("+1000000000000000000000000000");
bill->addChild(lb1);
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,nullptr);
auto rot = RotateBy::create(2,Vec3(-90,0,0));
auto act = Spawn::create(seq,rot ,NULL);//Spawn 同时动作
auto scale2 = scale->reverse();
auto rot2 = rot->reverse();
auto act2 = Spawn::create(scale2,rot2,NULL);
auto seq2 = Sequence::create(act,act2,NULL);//Sequence 顺序动作
auto repeat =RepeatForever::create(seq2);
mode1->runAction(repeat);
Billboard 上加动作Animation
void HelloWorld::addNewAniBillBoardWithCoords(Vec3 p)
{
for (int i = 0; i < 10; ++i)
{
auto billboardAni = BillBoard::create("Images/grossini.png");
billboardAni->setScale(0.5f);
billboardAni->setPosition3D(Vec3(p.x,p.y,-150.0f +30 *i));
_layerBillBoard->addChild(billboardAni);
auto animation = Animation::create();
for (int i = 1; i < 15; i++)
{
char szName1[100] = {0};
sprintf(szName1,"Images/grossini_dance_%02d.png",i);
animation->addSpriteFrameWithFile(szName1);
}
animation->setDelayPerUnit(2.8f / 14.0f);//设置两帧之间的时间间隔
animation->setRestoreOriginalFrame(true);//true: 动画播放结束后,回到初始帧 false:动画播放结束后,显示最后一帧
auto action = Animate::create(animation);
billboardAni->runAction(RepeatForever::create(action));
billboardAni->setOpacity(CCRANDOM_0_1() * 128 + 128);
//设置透明度
_billboards.push_back(billboardAni);
}
}
标签:
原文地址:http://blog.csdn.net/liubin8095/article/details/45112425