Letter::Letter(char letter, size_t id): letter(toupper(letter)), id(id){ // TODO - нужно либо делать rect метод чтобы правильный размер сделать // либо он на автомате будет работать. я не знаю CCSprite::init(); //this->setTouchEnabled(true); this->autorelease(); // TODO 1 раз получать - для всех использовать потом letterImage = CCSprite::create("letter32_2.png"); letterImage->setScale(32 / letterImage->getContentSize().width); char arr[2] = {this->letter, '\0'}; //CCLabelTTF *letterLabel = CCLabelTTF::create(arr, "fonts/Schwarzwald Regular.ttf", 22); //CCLabelTTF *left = CCLabelTTF::create("alignment left", pFont, fontSize, // blockSize, kCCTextAlignmentLeft, verticalAlignment[vAlignIdx]); //CCLabelTTF *letterLabel = CCLabelTTF::create(arr, /*"fonts\sylfaen.ttf"*/"Sylfaen", 50); //CCLabelBMFont *letterLabel = CCLabelBMFont::create(arr, "fonts/hd/markerFelt.fnt", 10); //letterLabel->setScale(0.5); CCLabelAtlas *letterLabel = CCLabelAtlas::create(arr, "fonts/hd/larabie-16.plist"); letterLabel->setAnchorPoint(ccp(0.5f, 0.5f)); letterLabel->setColor(ccc3(85,47,17)); //letterLabel->setColor(ccc3(0,0,0)); this->addChild(letterImage,1); this->addChild(letterLabel,2); }
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 将死亡 } }