void CGameMessage::update(float dt) { showScore(); showHp(); showLife(); showMissile(); }
void RpgPlayer::beAttacked(int atkValue) { if (hp <= 0) { return; } int oldhp = hp; if (hp >= atkValue) { hp -= atkValue; } else { hp = 0; } atkValue = oldhp-hp; if (atkValue) { std::stringstream ss; ss << atkValue; //CCLabelAtlas *labelAtlas = CCLabelAtlas::create(ss.str().c_str(),"fps_images.png", 12, 32, '.'); CCLabelAtlas *labelAtlas = CCLabelAtlas::create(ss.str().c_str(),"numbers_1.png", 41.28, 81, '.'); labelAtlas->setVisible(true); //labelAtlas->setPosition(ccp(125,125)); labelAtlas->setColor(ccc3(255,0,0)); CCAction *spawn = CCSpawn::create(CCMoveBy::create(0.5f,ccp(0,64)),CCFadeOut::create(0.5),NULL); labelAtlas->runAction(spawn); this->addChild(labelAtlas,2); CCSprite::runAction(CCSequence::create(CCDelayTime::create(0.6), CCCallFuncND::create(this, callfuncND_selector(RpgMonster::actionEnd_removeLabel), (void*)labelAtlas),NULL)); showHp(); tryConbineAction(RpgMonster::ACTION_BE_ATTACK); } if (ui) { ui->updateHp(this); } if (hp <=0) { doDeath(); // RpgMonster 将死亡 } }
bool RpgBuild::initWithBuild(RpgBuildInfo *buildInfo) { info = *buildInfo; if (info.maxHp) hp = info.maxHp; drawGrid(); if (info.buildName != "") buildSprite = CCSprite::create(info.buildName.c_str()); else buildSprite = CCSprite::create(); if (buildSprite) { this->addChild(buildSprite); CartoonInfo *info = MonsterManager::getMe().getCobineCartoon(buildInfo->name.c_str(), 0); if (info) { CCAnimate* animation = CCAnimate::create(info->createAnimation()); buildSprite->runAction(CCRepeatForever::create(animation)); } } showHp(); return true; }