void SpriteMonsterArcher::initEffect(unsigned int effectId) { if(effectInited) { return; } effectNodes.clear(); LevelLayer * layer = LevelManager::sShareInstance()->getCurrentLevelLayer(); if (!layer) { ASSERT(0, "LevelLayer is NULL"); return; } for (int i = 0; i < EFFECT_COUNT; i++) { CCNode * effectNode = CCNode::create(); EffectSprite * skillAnim = ParticleManager::Get()->createEffectSprite(effectId,""); skillAnim->SetAnim(kType_Play, 1, true); effectNode->addChild(skillAnim); effectNode->setVisible(false); //添加到动态管理层 effectNodes.push_back(effectNode); layer->getObjectLayer()->addChild(effectNodes[i], LevelLayer::sCalcZorder(m_oldPos)); } effectInited = true; }
void DamageValueEffect::HandleCritBurst(CCPoint pt, unsigned int effectType) { unsigned int effectId = effectType; if(effectId == 0) { effectId = rand() % 3 + 152; } EffectSprite* effect = ParticleManager::Get()->createEffectSprite(effectId,"",false); if(effect) { effect->setPosition(pt); float scale = UIManager::sharedManager()->getScaleFactor(); effect->getRoot()->setScale(scale); effect->SetAnim(kType_Play,1,false); if(m_pDamageLabels->find(effect) == m_pDamageLabels->end()) { m_pDamageLabels->insert(make_pair(effect,1.0f)); //this->addChild(critNode); if(GameManager::Get()->GetSceneLayer() != NULL && GameManager::Get()->GetSceneLayer()->getLevelLayer() != NULL && GameManager::Get()->GetSceneLayer()->getLevelLayer()->getObjectLayer()) { GameManager::Get()->GetSceneLayer()->getLevelLayer()->getObjectLayer()->addChild(effect,MAP_Z_OBJ_TOP); } } } }
//---------------------------------------------------------------------------------------- // others function means other players' //---------------------------------------------------------------------------------------- void BaseLevelBuilder::addMonster(MonsterInitInfo info) { std::map<uint32_t, SpriteMonster*>::iterator itor = m_level->m_MonsterInfo.find(info.uid); if (itor == m_level->m_MonsterInfo.end()) { //add monster ASSERT(m_level->m_levelDataReference->mapFilePointer != NULL, "map file is empty"); SpriteMonster* monster = LevelObjectCreator::sCreateSpriteMonster(info); monster->SetID(info.uid); monster->setTag(MAP_TAG_MONSTER); monster->setPosition(info.pos); //printf("addMonster %f, %f\n", info.pos.x, info.pos.y); //添加阴影 /*ASprite* pAsprite = AspriteManager::getInstance()->getAsprite("spriteBin/shadow.bin"); if(pAsprite != NULL) { CCPoint cp; CCSprite* pCSprite = pAsprite->getSpriteFromFrame(0, 0, cp); if(pCSprite != NULL) { pCSprite->setPosition(ccp(0, 0)); pCSprite->setTag(SHADOW_TAG); monster->addChildToRoot(pCSprite); } }*/ CATLObjectLayer* pObjLayer = dynamic_cast<CATLObjectLayer*>(m_level->m_pObjectsLayer); if(pObjLayer) { pObjLayer->AddRoleShadow(monster); } //为精英怪添加特效 if(info.isElite) { EffectSprite * eliteEffect = ParticleManager::Get()->createEffectSprite(206,""); eliteEffect->SetAnim(kType_Play, 1, true); eliteEffect->setTag(ELITE_TAG); monster->addChildToRoot(eliteEffect); } if (m_level->m_pObjectsLayer) { m_level->m_pObjectsLayer->addChild(monster, LevelLayer::sCalcZorder(monster->getPosition())); } m_level->m_MonsterInfo.insert(std::pair<uint32_t, SpriteMonster*>(info.uid, monster)); } else { CCLog("error, the player has add before"); } }
void BaseLevelBuilder::createMonsterBornPoints() { vector<CCPoint> points = InstanceManager::Get()->getMonsterBornPoints(); for (size_t i = 0; i < points.size(); i++) { EffectSprite* monsterBornPoint = ParticleManager::Get()->createEffectSprite(205,""); monsterBornPoint->SetAnim(kType_Play,1,true); CCNode * bornNode = CCNode::create(); bornNode->addChild(monsterBornPoint); bornNode->setPosition(points[i]); m_level->addChild(bornNode, MAP_Z_TILE_BACKGROUND); } InstanceManager::Get()->clearMonsterBornPoints(); }