当前位置: 首页>>代码示例>>C++>>正文


C++ Tower::setOriginCharacterData方法代码示例

本文整理汇总了C++中Tower::setOriginCharacterData方法的典型用法代码示例。如果您正苦于以下问题:C++ Tower::setOriginCharacterData方法的具体用法?C++ Tower::setOriginCharacterData怎么用?C++ Tower::setOriginCharacterData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tower的用法示例。


在下文中一共展示了Tower::setOriginCharacterData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: createTower

Tower* ObjectFactory::createTower(TowerStructDTO* towerStructDTO, b2World* world)
{
    TowerDTO* towerDTO = DataCollector::getInstance()->getTowerDTOByKey(towerStructDTO->id.c_str());
    Tower* tower = NULL;
    if(strcasecmp(towerStructDTO->type.c_str(), "main") == 0)
    {
        tower = MainCrystal::create();
//        CCLOG("main");
    }
    else
    {
        tower = Tower::create();
//        CCLOG("tower");
    }
    
    
    tower->setOriginCharacterData(towerDTO->data);
    
    //Create Animation
    string run = towerDTO->animation;
    string attack = towerDTO->animation;
    string idle = towerDTO->animation;
    string fall = towerDTO->animation;
    string fly = towerDTO->animation;
    string jump = towerDTO->animation;
    string die = towerDTO->animation;
    
    tower->runAnimation = DataCollector::getInstance()->getAnimationObjectByKey(run.append(RUN).c_str());
    tower->attackAnimation = DataCollector::getInstance()->getAnimationObjectByKey(attack.append(ATTACK).c_str());
    tower->jumpAnimation = DataCollector::getInstance()->getAnimationObjectByKey(jump.append(JUMP).c_str());
    tower->idleAnimation = DataCollector::getInstance()->getAnimationObjectByKey(idle.append(IDLE).c_str());
    tower->fallAnimation = DataCollector::getInstance()->getAnimationObjectByKey(fall.append(FALL).c_str());
    tower->flyAnimation = DataCollector::getInstance()->getAnimationObjectByKey(fly.append(FLY).c_str());
    tower->dieAnimation = DataCollector::getInstance()->getAnimationObjectByKey(die.append(DIE).c_str());
    tower->setSoundData(SoundManager::loadCharacterSoundData(towerDTO->soundId.c_str()));
//    if( tower->attackAnimation != NULL)
//    {
//        tower->attackAnimation->getAnimation()->setDelayPerUnit(tower->getOriginCharacterData().getAttackSpeed());
//    }
    
    
    //body
    b2BodyDef bodyDef;
    bodyDef.type = b2_dynamicBody;
    bodyDef.angle = ccpToAngle(ccp(0,0));
    bodyDef.fixedRotation=true;
    
    b2Body *body = world->CreateBody(&bodyDef);
    
    gbox2d::GB2ShapeCache *sc =  gbox2d::GB2ShapeCache::sharedGB2ShapeCache();
    sc->addFixturesToBody(body,  towerDTO->body.c_str());
    tower->setSpriteAnchorPoint(sc->anchorPointForShape(towerDTO->body.c_str()));
    tower->getSprite()->setAnchorPoint(sc->anchorPointForShape(towerDTO->body.c_str()));
    tower->setSkin(body, tower->getSprite());
    
    //
    tower->setSensor(towerDTO->towerSensorId.c_str());
    
    tower->setSkill(NORMAL_ATTACK, SkillFactory::createSkill(towerDTO->data.getSkill0().c_str(), world, tower, false, SKILL_0_BTN));
    //    tower->setSkill1(SkillFactory::createSkill(towerDTO->data.getSkill1().c_str(), world, tower, false, SKILL_1_BUTTON));
    //    tower->setSkill2(SkillFactory::createSkill(towerDTO->data.getSkill2().c_str(), world, tower, false, SKILL_2_BUTTON));
    
    tower->setPositionInPixel(ccp(towerStructDTO->positionX,towerStructDTO->positionY));
    tower->setGroup(towerStructDTO->group);
    
    tower->setSoundData(SoundManager::loadCharacterSoundData(towerDTO->soundId.c_str()));
    
    tower->onCreate();
    return tower;
}
开发者ID:quinsmpang,项目名称:TinyZodiacs,代码行数:70,代码来源:ObjectFactory.cpp


注:本文中的Tower::setOriginCharacterData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。