void CLifeObject::SetAttackAnimation() { // TODO : delete auto animationCashe = AnimationCache::getInstance(); auto spriteFrameCashe = SpriteFrameCache::getInstance(); //// int idAnimation = GetIndexAttackAnimation(m_direction); if (getActionByTag(idAnimation) == nullptr) { Animate *oldAnimate = GetOldAnimate(); Animation *animation = m_type->GetAttackAnimations().at(idAnimation - rangesDirections.size()); Animate *newAnimate = Animate::create(animation); newAnimate->setTag(idAnimation); if (oldAnimate != nullptr) { if (oldAnimate->getTag() != newAnimate->getTag()) { newAnimate->setDuration(oldAnimate->getDuration()); } } runAction(newAnimate); } }
void SkillEffectShow::playExplosionSpecific(const char *path) { m_explosionSprite = Sprite::create(); if (m_skillInfo.getIsThirdParty() == true) { Point point = m_showSprite->getPosition(); m_explosionSprite->setPosition(point); GAME_SCENE->getCurrBgMap()->addChild(m_explosionSprite); Point high = ((Monomer*)m_attacker->getParent())->getHurtPointRelativeFootOffset(); //setZOrder m_explosionSprite->setLocalZOrder(BgMap::getZOrder(ccpSub(point, high)) + 1); } else { Monomer* victim = (Monomer*)m_victim->getParent(); if (victim == NULL) { this->releaseThis(); return; } float x = victim->getContentSize().width * victim->getFigure()->getAnchorPointCenter().x; float y = victim->getContentSize().height * victim->getFigure()->getAnchorPointCenter().y; m_explosionSprite->setPosition(Point(x, y)); m_victim->addChild(m_explosionSprite); } int flag = 0; //CCArray* array = CCArray::createWithCapacity(4); Vector<SpriteFrame*> array ; do { CCString* string = CCString::createWithFormat("%s_%02d.png", path, flag); SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(string->getCString()); CC_BREAK_IF(spriteFrame == NULL); array.pushBack(spriteFrame); flag++; } while (1); if (array.size() > 0) { Animation* movie = Animation::createWithSpriteFrames(array, 1 / (float)24); Animate* animate = Animate::create(movie); CallFunc* finish = CallFunc::create(this, callfunc_selector(SkillEffectShow::releaseThis)); Sequence* actions1 = Sequence::create(animate, finish, NULL); DelayTime* delay = DelayTime::create(animate->getDuration()/2); CallFunc* callFunc = CallFunc::create(this, callfunc_selector(SkillEffectShow::sendMessage)); Sequence* actions2 = Sequence::create(delay, callFunc, NULL); Spawn* spawn = Spawn::create(actions1, actions2, NULL); m_explosionSprite->runAction(spawn); } else { this->sendMessage(); this->releaseThis(); } }