是mac 版本的。打开运行一会后,就会出现人物播放动画的时候卡死了,个人人物有三个技能动画和一个攻击动画,他们交替播放的时候某一个动画(随机的)播放到一半就会停止。还是水平太低了。实在是找不到问题所在,求大神帮我看看。在线等要源代码的可以留邮箱,这网站实在是传不上去。求大神们仔细看看。
这个是释放技能1的函数
skill1Key(CCCallFuncN::create(this, callfuncN_selector(XiaoYing::judgeWhetherStopRunAnimate1)));
这个是回调函数,每个技能我都是每一个对应的回调函数
void XiaoYing::judgeWhetherStopRunAnimate1(cocos2d::CCNode *pNode)
{
judge();
}
void XiaoYing::judge()
{
isRunSkill = false;
isRunAttact = false;
isRunArriveTagetPoint = true;
CCRepeatForever *idleAction= CCRepeatForever::create(idle);
idleAction->setTag(3);
pSprite->runAction(idleAction);
}
//这个是基类的实现函数
void PlayerBase::skill1Key(CCCallFuncN *callfuncN)
{
if (isSkill1CD == false && isRunSkill == false) {
isSkill1CD = true;
isRunSkill = true;
if (playerName == "Konan") {
konanWalk->setVisible(false);
pSprite->setVisible(true);
}
//运行技能动画
runAnimate(skill1Ani,callfuncN,1);
//冷却相关
CCPoint parentPoint = ccp(-1000,-1000);
CCPoint childPoint = ccp(-1000,-1000);
scheduleOnce(schedule_selector(PlayerBase::skill1FreezeEnd), skill_1_FreezeTime);
if (isMainPlayer) {
parentPoint = getParent()->getParent()->getChildByTag(100)->getPosition();
childPoint = getParent()->getParent()->getChildByTag(100)->getChildByTag(1)->getPosition();
skillFreezeFun(102,skill_1_FreezeTime,ccp(parentPoint.x + childPoint.x,parentPoint.y + childPoint.y));
}
}
}
//运行动画
void PlayerBase::runAnimate(CCAnimate *animate,CCCallFuncN callfuncN,int selectRect)
{
//停止跑动,停止休息动画,停止左右跑
this->stopActionByTag(1);
pSprite->stopActionByTag(1);
pSprite->stopActionByTag(2);
pSprite->stopActionByTag(3);
//播放动画
CCAction skillAction = CCSequence::create(CCRepeat::create(animate,1),callfuncN,NULL);
if (selectRect == 0) {
skillAction->setTag(10);
}else
{
if (pSprite->getActionByTag(10)) {
pSprite->stopActionByTag(10);
}
}
pSprite->runAction(skillAction);
//纪录当前播发的动画
curAni = animate;
//纪录当前选择的碰撞矩形
this->selectRect = selectRect;
}
// 接下来是更新函数里面的人物循环函数
void XiaoYing::myAIControl(float dt)
{
if (!isMainPlayer && !isRunSkill) {
//找到了攻击目标并移动到攻击目标
PlayerBase * tagetPlayer = moveToTaget();
if (tagetPlayer != NULL) {
//执行不需要碰撞检测的技能
if(noNeedCrachChackSkill())
return;
//检测和目标是否碰撞了
if(crachChack(tagetPlayer))
{
//选择要释放的技能
if(!selectSkill())
{
if (attact()) {
CCLOG("%s 普通攻击",getPlayerName().c_str());
}
}
}
}
}
if(isRunSkill || isRunAttact)
{
//扣血
vsSubBlood();
}
}
bool XiaoYing::noNeedCrachChackSkill()
{
if (!isSkill1CD && myAttribute.hp < 900)
{
skill1Key(CCCallFuncN::create(this, callfuncN_selector(XiaoYing::judgeWhetherStopRunAnimate1)));
return true;
}
else if (!isSkill3CD)
{
if(chackNearHavePeople())
{
skill3Key(CCCallFuncN::create(this, callfuncN_selector(XiaoYing::judgeWhetherStopRunAnimate3)));
return true;
}
}
return false;
}
bool XiaoYing::selectSkill()
{
if (!isSkill2CD)
{
skill2Key(CCCallFuncN::create(this, callfuncN_selector(XiaoYing::judgeWhetherStopRunAnimate2)));
return true;
}
return false;
}
bool XiaoYing::attact()
{
if(!isRunAttact)
{
attactKey(CCCallFuncN::create(this, callfuncN_selector(XiaoYing::judgeWhetherStopRunAnimate)));
return true;
}
return false;
}
