-
cocos2dx 利用CCOrbitCamera实现扑克牌翻牌效果
-
#include "HelloWorldScene.h"
-
#include "SimpleAudioEngine.h"
-
-
using namespace cocos2d;
-
using namespace CocosDenshion;
-
-
CCScene* HelloWorld::scene()
-
{
-
CCScene *scene = CCScene::create();
-
HelloWorld *layer = HelloWorld::create();
-
scene->addChild(layer);
-
return scene;
-
}
-
bool HelloWorld::init()
-
{
-
if ( !CCLayer::init() )
-
{
-
return false;
-
}
-
size = CCDirector::sharedDirector()->getWinSize();
-
-
-
CCLayerColor* background = CCLayerColor::create(ccc4(255, 180, 255, 255), size.width, size.height);
-
this->addChild(background);
-
-
actionIsDone = true;
-
-
createPoker();
-
-
return true;
-
}
-
-
-
void HelloWorld::createPoker()
-
{
-
-
CCSprite* pokerFront = CCSprite::create("poker_front.png");
-
pokerFront->setVisible(false);
-
pokerFront->setPosition(ccp(size.width/2, size.height/2));
-
this->addChild(pokerFront,1,123);
-
-
-
CCSprite* pokerBack = CCSprite::create("poker_back.png");
-
pokerBack->setPosition(pokerFront->getPosition());
-
this->addChild(pokerBack,1,321);
-
}
-
-
void HelloWorld::startOrbitAction()
-
{
-
-
CCSprite* pokerFront = (CCSprite*)this->getChildByTag(123);
-
-
CCSprite* pokerBack = (CCSprite*)this->getChildByTag(321);
-
-
float orbitTime = 1;
-
if (pokerFront->isVisible() == false && actionIsDone == true) {
-
actionIsDone = false;
-
-
-
//顺时钟翻转
CCOrbitCamera* orbitFront = CCOrbitCamera::create(orbitTime, 1, 0, 270, 90, 0, 0); -
CCSequence* sequenceFront = CCSequence::createWithTwoActions(CCShow::create(), orbitFront);
-
CCTargetedAction* targetFront = CCTargetedAction::create(pokerFront, sequenceFront);
-
-
CCOrbitCamera* orbitBack = CCOrbitCamera::create(orbitTime, 1, 0, 0, 90, 0, 0);
-
pokerBack->runAction(CCSequence::create(orbitBack, CCHide::create(), targetFront, CCCallFunc::create(this, callfunc_selector(HelloWorld::actionIsDownFunc)),NULL));
-
}else if(pokerFront->isVisible() == true && actionIsDone == true){
-
actionIsDone = false;
-
//逆时钟翻转
CCOrbitCamera* orbitFront = CCOrbitCamera::create(orbitTime, 1, 0, 270, 90, 180, 0); -
CCSequence* sequenceFront = CCSequence::createWithTwoActions(CCShow::create(), orbitFront);
-
CCTargetedAction* targetFront = CCTargetedAction::create(pokerBack, sequenceFront);
-
-
CCOrbitCamera* orbitBack = CCOrbitCamera::create(orbitTime, 1, 0, 0, 90, 0, 0);
-
pokerFront->runAction(CCSequence::create(orbitBack, CCHide::create(), targetFront, CCCallFunc::create(this, callfunc_selector(HelloWorld::actionIsDownFunc)),NULL));
-
}
-
}
-
-
void HelloWorld::actionIsDownFunc()
-
{
-
actionIsDone = true;
-
}
-
-
bool HelloWorld::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
-
{
-
-
startOrbitAction();
-
return true;
-
}
-
-
void HelloWorld::ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent){}
-
void HelloWorld::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent){}
-
void HelloWorld::onEnter()
-
{
-
CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 0, false);
-
CCLayer::onEnter();
-
}
-
void HelloWorld::onExit()
-
{
-
CCDirector::sharedDirector()->getTouchDispatcher()->removeDelegate(this);
-
CCLayer::onExit();
-
}
-
HelloWorld::~HelloWorld(){}
两张扑克牌资源:
-
相关阅读:
【杭电】[2016]数据的交换输出
【杭电】[2015]偶数求和
【杭电】[2015]偶数求和
【杭电】[2026]首字母变大写
【杭电】[2026]首字母变大写
【杭电】[2075]A|B?
【杭电】[2075]A|B?
【杭电】[2043]密码
【杭电】[2043]密码
SQL 06: 内连接 (多表查询)
-
原文地址:https://www.cnblogs.com/bhlsheji/p/5326409.html
Copyright © 2020-2023
润新知