本文整理汇总了C++中CCNode::reorderChild方法的典型用法代码示例。如果您正苦于以下问题:C++ CCNode::reorderChild方法的具体用法?C++ CCNode::reorderChild怎么用?C++ CCNode::reorderChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCNode
的用法示例。
在下文中一共展示了CCNode::reorderChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TrackPlayerAnim
bool StoryInstanceDirector::TrackPlayerAnim()
{
// Note: Add To Obj Layer
LevelLayer* pLayer = LevelManager::sShareInstance()->getCurrentLevelLayer();
CCNode* pObjLayer = pLayer->getObjectLayer();
std::map<unsigned int,StoryRoleBasicData> storyData = StoryDataCenter::Get()->GetStoryRoleBasicData();
std::map<unsigned int,StoryRoleBasicData>::iterator iter = storyData.begin();
while(iter != storyData.end())
{
bool bPosChanged = false;
SpriteSeer* pCurHero = GetOneRole((*iter).first);
std::map<unsigned int,StoryFrameData>::iterator frameIter = (*iter).second.mMapStoryFramesData.find((int)m_curFrame);
if (frameIter != (*iter).second.mMapStoryFramesData.end())
{
//// Note: 当前帧存在
StoryFrameData frameData = (*frameIter).second;
CCPoint pos = frameData.getRolePos();
// Note: 位置发生变化,移动位置,或者新创建角色
if (StoryFrameData::IsPosChanged(pos))
{
bPosChanged = true;
bool bVisiable = pCurHero->getRoot()->isVisible();
if (bVisiable == false)
{
pCurHero->getRoot()->setVisible(true);
}
pCurHero->setPosition(pos);
pObjLayer->reorderChild(pCurHero,LevelLayer::sCalcZorder(pos));
}
int actorId = frameData.getActorId();
if (actorId != -1)
{
pCurHero->SetAnim(actorId,0);
}
int nFlip = frameData.getFlip();
if (nFlip != -1)
{
if (nFlip == 0)
{
pCurHero->SetAnimFlipX(false);
}
else if (nFlip == 1)
{
pCurHero->SetAnimFlipX(true);
}
}
}
if (false == bPosChanged)
{
// Note: 不存在的情况下处理移动
if (false == bPosChanged)
{
unsigned int preFrameIndex = 0;
unsigned int nextFrameIndex = 0;
CCPoint prePoint = CCPointZero;
CCPoint nextPoint = CCPointZero;
if(StoryDataCenter::Get()->GetPreAndNextPointFrameData((*iter).first,(int)m_curFrame,preFrameIndex,nextFrameIndex,prePoint,nextPoint))
{
// Note: 处理移动
unsigned int sumMoveFrames = (nextFrameIndex - preFrameIndex);
unsigned int runningFrames = (int)m_curFrame - preFrameIndex;
if (runningFrames >= sumMoveFrames)
{
return false;
}
// Note: 运动速率
CCPoint dir = ccpSub(nextPoint,prePoint);
float distance = sqrt(ccpLengthSQ(dir));
float vPerFrame = distance/sumMoveFrames;
if(dir.x == 0 && dir.y == 0)
{
return false;
}
dir = ccpNormalize(dir);
CCPoint nowPoint = ccpAdd(prePoint,ccp(vPerFrame*runningFrames*dir.x,vPerFrame*runningFrames*dir.y));
pCurHero->setPosition(nowPoint);
pObjLayer->reorderChild(pCurHero,LevelLayer::sCalcZorder(nowPoint));
}
}
}
iter++;
}
return true;
}