2级和3级箭塔与初级箭塔只是替换了图片并且将攻击力、射程等提高,其他并无区别
高级箭塔也是高级塔中最好设计的,通过替换一些图片,增加例如发光的眼睛,飞翔的老鹰等动画即可。
不同之处在于增加1-2个技能
例如下方CossbowHunterTower,在shoot中增加一个技能,添加一个Int类型attackCount,每次攻击加1,每4次攻击使用1次技能。
这个塔技能设计的比较简单(不同原作),技能即秒杀效果,直接爆头,播放一个发光动画即可,具体代码参加github上
上方的TotemTower塔在于会根据周围敌人数量扔两种不同的图腾(原作不同情况用的图腾不同,本作没有设置这个功能,读者可自行设计),重载checknearestMonster,并且设置个bool类型设置为两个技能的CD,每隔5秒将该类型设置为true
voID TotemTower::checkNearestMonster(){ monstersCount = 0; auto instance = GameManager::getInstance(); auto monsterVector = instance->monsterVector; auto currMindistant = this->scope; BaseMonster *monsterTemp = NulL; for(int i = 0; i < monsterVector.size(); i++) { auto monster = monsterVector.at(i); double distance = this->getParent()->getposition().getdistance(monster->baseSprite->getposition()); if (distance < currMindistant && monster->getAttackByTower()) { currMindistant = distance; monsterTemp = monster; monstersCount++;//计算周围敌人个数 } } nearestMonster = monsterTemp;}
重载shoot函数,当敌人个数大于5个且技能CD变量为true即释放技能,其他 *** 作与初级箭塔类似
if(totemCD){ SoundManager::playTotemSpirits(); auto redTotem = RedTotem::create(); this->getParent()->addChild(redTotem); redTotem->shoot(nearestMonster->baseSprite->getposition() - this->getParent()->getposition() + Point(20,20)); auto violetTotem = VioletTotem::create(); this->getParent()->addChild(violetTotem); violetTotem->shoot(nearestMonster->baseSprite->getposition() - this->getParent()->getposition()- Point(20,20)); totemCD = false;}
释放技能的图腾也是个继承与子d类的子类,与炮塔的炮d类似
voID VioletTotem::shoot(Point point){ this->setposition(point);设置位置 sprite->runAction(Sequence::create(//播放动画序列 CallFuncN::create(CC_CALLBACK_0(VioletTotem::boom,this)),//首先播放爆炸动画 Animate::create(AnimationCache::getInstance()->getAnimation("TotemTower_VioletTotem")),//播放图腾自毁动画 CallFuncN::create(CC_CALLBACK_0(VioletTotem::removeBullet,NulL));//爆炸,与炮d类类似}以上就是高级箭塔,比较简单 总结
以上是内存溢出为你收集整理的[cocos2dx学习笔记]用cocos2dx3.X完成塔防游戏王国保卫战--防御塔(五)之高级箭塔全部内容,希望文章能够帮你解决[cocos2dx学习笔记]用cocos2dx3.X完成塔防游戏王国保卫战--防御塔(五)之高级箭塔所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)