//OrbitCamera 翻转(翻转时间,起始半径,半径差,起始z角,旋转z角差,起始x角,旋转x角差)
float flipTime = 0.5f;
//翻牌动画,显示背面,翻转90度,添加正面内容同时显示正面,翻转正面
auto showBack = CallFuncN::create(this, callfuncN_selector(CardGame::showBack));
auto flipBack = OrbitCamera::create(flipTime, 1, 0, 180, 105, 0, 0);//设成转90度却不是转成直角?!
auto addFrontContent = CallFuncN::create(this, callfuncN_selector(CardGame::addContent));
auto showFront = CallFuncN::create(this, callfuncN_selector(CardGame::showFront));
auto flipFront = OrbitCamera::create(flipTime, 1, 0, 285, 75, 0, 0);
//序列化这一系统action然后运行
auto sequence = Sequence::create(showBack, flipBack, addFrontContent, showFront, flipFront, nullptr);
sequence->setTag(kTagActionFlip);
//停止所有翻转动作(可能存在)再重新开始
option->stopActionByTag(kTagActionFlip);
option->runAction(sequence);
//显示为背面
void CardGame::showBack(Node* pSender)
{
auto sprite = (Sprite*)pSender;
auto back = SpriteFrame::create("cardgame/card_back.png", Rect(0, 0, 238, 260));
sprite->setDisplayFrame(back);
}
//显示为正面
void CardGame::showFront(Node* pSender)
{
auto sprite = (Sprite*)pSender;
auto front = SpriteFrame::create(String::createWithFormat("cardgame/card_front_%d.png",
(pSender->getTag()))->getCString(), Rect(0, 0, 238, 260));
sprite->setDisplayFrame(front);
}
//添加正面的内容
void CardGame::addContent(Node* pSender)
{
int i = pSender->getTag();
auto content = Sprite::create(letterPath[cardType][cardIndex[i]]);
content->setPosition(Vec2( pSender->getContentSize().width*0.5,pSender->getContentSize().height*0.5 ));
pSender->addChild(content, 1, kTagCardContent + i );
}