本文整理汇总了C++中CCMoveTo::setTag方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMoveTo::setTag方法的具体用法?C++ CCMoveTo::setTag怎么用?C++ CCMoveTo::setTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMoveTo
的用法示例。
在下文中一共展示了CCMoveTo::setTag方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: powf
void Game2Scene::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)
{
if (!m_isMoving)
{
m_isMoving = true;
//タッチ初期値
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCTouch *touch = (CCTouch *)pTouches->anyObject();
CCPoint location = touch->getLocationInView();
location = CCDirector::sharedDirector()->convertToGL(location);
//スプライト呼び出し
CCSprite *player = (CCSprite *)this->getChildByTag(4);
//プレイヤーの移動範囲
if (location.x < 150 )
{
//プレイヤーの出現
float Length = powf(location.x - player->getPositionX(), 2.0f) + powf(location.y - player->getPositionY(), 2.0f);
float Duration = Length / winSize.width * 1.5f / speed;//移動に必要な時間
//タッチイベント
CCMoveTo* actionMove = CCMoveTo::create(Duration, location);
actionMove->setTag(26);
// actionMoveだけを止める
player->stopActionByTag(26);
player->runAction(actionMove);
}
}
}
示例2: _callbackForAction
void GoBattleLayer::_callbackForAction() {
CCMoveTo* pMoveTo = CCMoveTo::create(ANIMATION_DURING / 2, ccp(0.0f, 615.0f + m_pGameState->getBottomOffset()));
pMoveTo->setTag(MOVEIN_TAG);
m_pBgSprite->runAction(pMoveTo);
/* 更新上阵武将列表 */
updateHeroUi();
m_isInScreen = true;
}
示例3: resumeMapAction
void MapEventsNode::resumeMapAction()
{
CCSize size = ToolsFun::sharedTools()->getSceneSize();
float scale = size.height / 800.0f;
m_tmxTiledMap->stopActionByTag(11123);
m_pauseMove = false;
float time1 = m_mapHt/(m_speed);/*地图移动完所需时间*/
CCMoveTo *moveTo = CCMoveTo::create(time1 * 1.0f/scale, ccp(0,-m_mapHt*1.0f/scale));
moveTo->setTag(11123);
m_tmxTiledMap->runAction(moveTo);
}
示例4: restoreTouchUICompent
void GoBattleLayer::restoreTouchUICompent() {
/*恢复可见*/
this->setVisible(true);
if (m_pBgSprite->getActionByTag(MOVEOUT_TAG)) {
m_pBgSprite->stopAllActions();
m_pBgSprite->setPosition(ccp(0, 975.0f + m_pGameState->getBottomOffset()));
CCMoveTo* pMoveTo = CCMoveTo::create(ANIMATION_DURING, ccp(0.0f, 615.0f + m_pGameState->getBottomOffset()));
pMoveTo->setTag(MOVEIN_TAG);
m_pBgSprite->runAction(pMoveTo);
return;
}
if (!m_pBgSprite->getActionByTag(MOVEIN_TAG)) {
CCMoveTo* pMoveTo = CCMoveTo::create(ANIMATION_DURING, ccp(0.0f, 615.0f + m_pGameState->getBottomOffset()));
pMoveTo->setTag(MOVEIN_TAG);
m_pBgSprite->runAction(pMoveTo);
}
/* 将谁调用武将列表标志置空,不置空会出错 */
m_pGameState->setTagWhoCallHeroSel(WCH_NONE);
m_isInScreen = true;
}
示例5: MoveMyPlayerToSelectedIndex
void StageMapLayer::MoveMyPlayerToSelectedIndex(float deltaTime)
{
const int StageMapPlayerActionTag = 37;
const float speed = 100.f; // pixel per sec
INT currentDestinationIndex = m_CurrentMyPlayerStageMapPointIndex+1;
if( m_CurrentMyPlayerStageMapPointIndex < m_SelectedStageMapPointIndex )
{
currentDestinationIndex = m_CurrentMyPlayerStageMapPointIndex+1;
}
else if( m_CurrentMyPlayerStageMapPointIndex > m_SelectedStageMapPointIndex)
{
currentDestinationIndex = m_CurrentMyPlayerStageMapPointIndex-1;
}
else
{
ASSERT_DEBUG( m_CurrentMyPlayerStageMapPointIndex == m_SelectedStageMapPointIndex);
currentDestinationIndex = m_SelectedStageMapPointIndex;
}
if( currentDestinationIndex<=0 )
{
currentDestinationIndex = 0;
}
else if( currentDestinationIndex >= m_StageMapPointList.size() )
{
currentDestinationIndex = m_SelectedStageMapPointIndex = m_StageMapPointList.size()-1;
}
StageMapPoint* destinationStageMapPoint = m_StageMapPointList[currentDestinationIndex];
const CCPoint destination = destinationStageMapPoint->getPosition()+m_PlayerPositionOffset;
if( m_CurrentMyPlayerStageMapPointIndex != m_SelectedStageMapPointIndex )
{
StageMapPoint* currentStageMapPoint = m_StageMapPointList[m_CurrentMyPlayerStageMapPointIndex];
if( destinationStageMapPoint->getPositionX() - currentStageMapPoint->getPositionX() < 0 )
{
if( m_MyPlayer->IsFlipX() == true )
{
m_MyPlayer->FlipX(false);
}
}
else if( destinationStageMapPoint->getPositionX() - currentStageMapPoint->getPositionX() > 0 )
{
if( m_MyPlayer->IsFlipX() == false )
{
m_MyPlayer->FlipX(true);
}
}
}
if( destination.getDistance(m_MyPlayer->getPosition()) >= speed*0.06f )
{
m_MyPlayer->setPosition( m_MyPlayer->getPosition() + (destination-m_MyPlayer->getPosition()).normalize() * speed * deltaTime );
const float duration = destination.getDistance(m_MyPlayer->getPosition())/speed;
CCMoveTo* moveAction = CCMoveTo::create(duration, destination);
moveAction->setTag(StageMapPlayerActionTag);
m_MyPlayer->stopActionByTag(StageMapPlayerActionTag);
m_MyPlayer->runAction( moveAction );
}
else
{
m_CurrentMyPlayerStageMapPointIndex = currentDestinationIndex;
m_MyPlayer->setZOrder(destinationStageMapPoint->getZOrder());
if( m_CurrentMyPlayerStageMapPointIndex != m_SelectedStageMapPointIndex )
{
this->MoveMyPlayerToSelectedIndex(deltaTime);
}
else
{
m_MyPlayer->stopActionByTag(ActionType_Animation);
m_MyPlayer->AnimateIdle();
}
}
}
示例6: SelectStageMapPoint
void StageMapLayer::SelectStageMapPoint(INT listIndex, BOOL withAnimation)
{
if( listIndex <= 0 )
{
listIndex = 0;
}
ASSERT_DEBUG(m_StageMapPointList.size() > listIndex );
INT oldIndex = m_SelectedStageMapPointIndex;
m_SelectedStageMapPointIndex = listIndex;
const CCSize winSize = CCDirector::sharedDirector()->getWinSize();
StageMapPoint* stageMapPoint = m_StageMapPointList[listIndex];
const StageLevel stageLevel = stageMapPoint->GetStageLevel();
StageInfo* stageInfo = StageInfoDictionary::Instance().FindStageInfo(stageLevel);
CCPoint destination = ccp(stageInfo->GetMapPosition().x, stageInfo->GetMapPosition().y)+m_PlayerPositionOffset;
CCPoint mapDestination = ccp(m_MapBase->getPositionX(), winSize.height*0.5f+(-stageInfo->GetMapPosition().y));
if( withAnimation == true )
{
CCCallFunc* jumpCall = CCCallFunc::create(m_MyPlayer, callfunc_selector(PlayerNode::AnimateWholeJump));
CCDelayTime* jumpDelay = CCDelayTime::create(m_MyPlayer->GetWholeJumpAnimationPlayTime());
CCSequence* jump = CCSequence::create(jumpCall, jumpDelay, nullptr);
CCRepeatForever* repeatJump = CCRepeatForever::create(jump);
repeatJump->setTag(ActionType_Animation);
m_MyPlayer->stopActionByTag(ActionType_Animation);
m_MyPlayer->runAction(repeatJump);
const int StageMapPlayerActionTag = 37;
this->MoveMyPlayerToSelectedIndex(0.f);
CCMoveTo* moveMap = CCMoveTo::create(1.f, mapDestination);
moveMap->setTag(StageMapPlayerActionTag);
m_MapBase->stopActionByTag(StageMapPlayerActionTag);
m_MapBase->runAction( moveMap );
}
else
{
m_CurrentMyPlayerStageMapPointIndex = m_SelectedStageMapPointIndex;
m_MyPlayer->setPosition(destination);
m_MapBase->setPosition(mapDestination);
if( stageMapPoint !=nullptr )
{
m_MyPlayer->setZOrder(stageMapPoint->getZOrder());
}
}
if( stageMapPoint !=nullptr )
{
stageMapPoint->SetFloatingMode(false);
}
if( oldIndex >= 0 && oldIndex < m_StageMapPointList.size() )
{
StageMapPoint* oldStageMapPoint = m_StageMapPointList[oldIndex];
oldStageMapPoint->SetFloatingMode(true);
}
// To Do : PopUp Change
m_MissionBox->Initialize(*stageInfo);
m_TitleBox->Initialize(*stageInfo);
}
示例7: update
void Duck::update(float dt)
{
if(currentState == kStateAlive)
{
if(!canEscape)
{
cuakSFX += dt;
if(cuakSFX >= 1.5f)
{
SimpleAudioEngine::sharedEngine()->playEffect("cuak.mp3");
cuakSFX = 0.0f;
}
if(getActionByTag(TAG_ACTION_MOVE) == NULL)
{
CCPoint newPosition;
float distance, time;
if(!_paths.empty())
{
DuckStateAnimation newState = kAnimationRight;
newPosition = _paths[_paths.size() - 1];
_paths.pop_back();
distance = ccpDistance(newPosition, getPosition());
time = distance / speed;
float angle = atan2f(newPosition.y - getPositionY(), newPosition.x - getPositionX()) * 180 / PI + 180;
bool left = newPosition.x < getPositionX();
if(left && angle < 180)
newState = kAnimationLeft;
else if(left && angle >= 180)
newState = kAnimationDLeft;
else if(!left && angle >= 180)
newState = kAnimationDRight;
if(newState != currentAnimation)
{
currentAnimation = newState;
_runAnimation();
}
CCMoveTo* moveToAction = CCMoveTo::create(time, newPosition);
moveToAction->setTag(TAG_ACTION_MOVE);
runAction(moveToAction);
}
else
{
canEscape = true;
if(getPositionY() < END_DUCK_Y)
{
currentAnimation = kAnimationEscape;
_runAnimation();
newPosition = ccp(getPositionX(), END_DUCK_Y);
distance = ccpDistance(newPosition, getPosition());
time = distance / speed;
CCMoveTo* moveToAction = CCMoveTo::create(time, newPosition);
moveToAction->setTag(TAG_ACTION_MOVE);
runAction(moveToAction);
}
}
}
}
}
if(canEscape && getPositionY() + getContentSize().height * 1.5f >= END_DUCK_Y)
{
speed -= SPEED_INCREMENT;
reset();
}
}