本文整理汇总了C++中BaseSprite类的典型用法代码示例。如果您正苦于以下问题:C++ BaseSprite类的具体用法?C++ BaseSprite怎么用?C++ BaseSprite使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BaseSprite类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testMessage
void taskLayer::testMessage(Ref * message) {
BaseSprite * sprite = dynamic_cast<BaseSprite *> (message);
std::string name = sprite->getM_name();
ValueMap taskMap = DataXML::getInstence()->getTask();
for (auto taskName : taskMap)
{
std::string taskKey = taskName.first.c_str();
if (name == taskKey)
{
for(auto v :allCondition){
std::string key = v.first.c_str();
if (name == key && allCondition.at(name).asInt() < taskMap.at(name).asInt())
{
//增加吃到道具数量达到任务要求后的处理!!!!!!!!!!!!!!!!!!!!别忘了
int number = allCondition.at(name).asInt() + 1;
allCondition[key] = number;
//更改Label显示,更换黄匡
changeDisplay(name);
}
}
}
}
}
示例2: select
void GongJiang_EquipSelect::select()
{
CCTableViewCell* lastCell = mTableView->cellAtIndex(0);
if (lastCell)
{
BaseSprite* bg = (BaseSprite*)lastCell->getChildByTag(TAG_EquipBaseBody_TABLE_ITEM);
bool isFirstIn = false;
// 先不管是否点击了图片
if(GameGuideManager::getManager()->isGuideNow(GameGuideManager::GID_GongJiang_QiangHua))
{
//GameGuideManager::getManager()->setOneGuideStart(GameGuideManager::GID_GongJiang_SelectZhuangBei);
//GameGuideManager::getManager()->setOneGuideEnd(GameGuideManager::GID_GongJiang_SelectZhuangBei);
if (bg)
{
CCPoint pos = bg->getParent()->convertToWorldSpace(bg->getPosition());
GuideLayerBase *guideLayer1 = new GuideLayer_SimpleLayer;
guideLayer1->init(bg->getContentSize(), ccp(pos.x,pos.y + bg->getContentSize().height / 2)
, LFStrings::getValue("qiangxuanzezhuangbei"), NULL, false);
//((GuideLayer_SimpleLayer*)guideLayer1)->setCallBack(this,SEL_CallFunc(&JiuGongGeLayer::GuiDeLayerCallBack));
CCDirector::sharedDirector()->getRunningScene()->addChild(guideLayer1, 128);
}
}
}
}
示例3: BaseSprite
BaseSprite* BaseSprite::create(string fileName)
{
BaseSprite* s = new BaseSprite();
s->initWithFile(fileName.c_str());
s->autorelease();
return s;
}
示例4: BaseSprite
BaseSprite * BaseSprite::create( const char *fileName )
{
BaseSprite *bs = new BaseSprite();
if(bs&&bs->initWithFile(fileName))
{
bs->autorelease();
return bs;
}
return NULL;
}
示例5: correctSize
void UIButton::correctSize() {
Rect32 rect;
BaseSprite *img = nullptr;
if (_image) {
img = _image;
} else if (_imageDisable) {
img = _imageDisable;
} else if (_imageHover) {
img = _imageHover;
} else if (_imagePress) {
img = _imagePress;
} else if (_imageFocus) {
img = _imageFocus;
}
if (_width <= 0) {
if (img) {
img->getBoundingRect(&rect, 0, 0);
_width = rect.right - rect.left;
} else {
_width = 100;
}
}
if (_height <= 0) {
if (img) {
img->getBoundingRect(&rect, 0, 0);
_height = rect.bottom - rect.top;
}
}
if (_text) {
int textHeight;
if (_font) {
textHeight = _font->getTextHeight((byte *)_text, _width);
} else {
textHeight = _gameRef->getSystemFont()->getTextHeight((byte *)_text, _width);
}
if (textHeight > _height) {
_height = textHeight;
}
}
if (_height <= 0) {
_height = 100;
}
if (_back) {
_back->correctSize(&_width, &_height);
}
}
示例6: CCLOG
void SpriteSystem::itemCallback(Ref* pSender, int Num)
{
m_itItem[Num]->setEnabled(false);
CCLOG("Num%d", Num);
BaseSprite* hero = m_vHeros.at(Num);
hero->setCurPower(0);
hero->startAction(SPRITESTATE_MAGIC);
//释放大招
Magic* bigMagic = Magic::create(m_magConf[hero->getSpConf().magicGroup.magic2]);
bigMagic->startMagic(hero, hero->getMagicTargetSP(), 0);
this->addChild(bigMagic,2);
// this->startMagic(m_bsSp[Num], m_bsSp[Num]->getSpConf().magicGroup.magic2, 3);
}
示例7: new
BaseSprite* BaseSprite::create()
{
BaseSprite* pRet = new(std::nothrow) BaseSprite();
if (pRet && pRet->init()) {
pRet->autorelease();
return pRet;
}
else {
delete pRet;
pRet = nullptr;
return nullptr;
}
}
示例8: messageMoveDone
void MainFooterLayer::messageMoveDone(CCNode* pInfoStr)
{
BaseSprite *messageBar = (BaseSprite*)this->getChildByTag(Tag_MessageInfoBar);
if (messageBar)
{
// NetLabelTTF* pLable = (NetLabelTTF*)messageBar->getChildByTag(Tag_MessageTipStr);
// if (!pLable)
// {
if (SystemPushMessagePool::getPool()->getCurMsgCount() < 1)
{
messageBar->removeFromParent();
}
// }
}
}
示例9: update
bool AdSentence::update(TDirection dir) {
if (!_talkDef) {
return STATUS_OK;
}
uint32 currentTime;
// if sound is available, synchronize with sound, otherwise use timer
/*
if (_sound) CurrentTime = _sound->GetPositionTime();
else CurrentTime = _gameRef->_timer - _startTime;
*/
currentTime = _gameRef->_timer - _startTime;
bool talkNodeFound = false;
for (uint32 i = 0; i < _talkDef->_nodes.size(); i++) {
if (_talkDef->_nodes[i]->isInTimeInterval(currentTime, dir)) {
talkNodeFound = true;
BaseSprite *newSprite = _talkDef->_nodes[i]->getSprite(dir);
if (newSprite != _currentSprite) {
newSprite->reset();
}
_currentSprite = newSprite;
if (!_talkDef->_nodes[i]->_playToEnd) {
break;
}
}
}
// no talk node, try to use default sprite instead (if any)
if (!talkNodeFound) {
BaseSprite *newSprite = _talkDef->getDefaultSprite(dir);
if (newSprite) {
if (newSprite != _currentSprite) {
newSprite->reset();
}
_currentSprite = newSprite;
} else {
_currentSprite = NULL;
}
}
return STATUS_OK;
}
示例10: BaseSprite
bool AdEntity::setSprite(const char *filename) {
if (_currentSprite == _sprite) {
_currentSprite = nullptr;
}
delete _sprite;
_sprite = nullptr;
BaseSprite *spr = new BaseSprite(_gameRef, this);
if (!spr || DID_FAIL(spr->loadFile(filename))) {
delete _sprite;
_sprite = nullptr;
return STATUS_FAILED;
} else {
_sprite = spr;
_currentSprite = _sprite;
return STATUS_OK;
}
}
示例11: assert
PointerList<BaseSprite*>* Spritesheet::ExtractSprites()
{
assert(this->ConfigFilePath != "");
assert(this->SpritesheetFilePath != "");
assert(this->Graphics != NULL);
PointerList<BaseSprite*>* spriteList = new PointerList<BaseSprite*>();
XmlReader configReader = XmlReader();
configReader.LoadFile(this->ConfigFilePath);
PointerList<XmlNode*>* nodes = configReader.FindNodes("sprite");
auto it = nodes->GetContainer()->begin();
while (it != nodes->GetContainer()->end())
{
XmlNode* node = (*it);
std::string spriteName = node->GetAttribute("n").AttributeValue;
int spriteSubTextureX = std::atoi(node->GetAttribute("x").AttributeValue);
int spriteSubTextureY = std::atoi(node->GetAttribute("y").AttributeValue);
int spriteSubTextureW = std::atoi(node->GetAttribute("w").AttributeValue);
int spriteSubTextureH = std::atoi(node->GetAttribute("h").AttributeValue);
FRectangle subRec = FRectangle(spriteSubTextureX, spriteSubTextureY, spriteSubTextureW, spriteSubTextureH);
BaseSprite* newSprite = Graphics->CreateSpriteInstance();
newSprite->Ident = spriteName;
BaseTexture* newSpriteTexture = spritesheetTexture->GetSubTexture(subRec);
newSprite->SetTexture(newSpriteTexture);
newSpriteTexture->TextureName = spriteName;
newSpriteTexture->TexturePath = this->SpritesheetFilePath;
spriteList->Add(newSprite);
it++;
}
nodes->Release();
delete(nodes);
return spriteList;
}
示例12: rsp_DuanZao
void ChuanqiduanzaoItem::rsp_DuanZao(CCObject *msg_f)
{
CCNotificationCenter::sharedNotificationCenter()->removeObserver(this, MSG_DuanzaoRsp_F);
GameDirector::getDirector()->hideWaiting();
Flat_DuanzaoRsp *data = (Flat_DuanzaoRsp*)((Flat_MSG_Rsp*)msg_f)->getData();
if (data->err_code != Success)
{
if (data->err_code == CEC_NoMoreFreeSpaceToStoreEquip)
{
EquipBagNotEnoughDialog *layer = new EquipBagNotEnoughDialog;
layer->showGoToFenJieDialog();
}
else
{
MessageDisplay *layer = MessageDisplay::create(CmdHelper::getHelper()->getMessage(data->err_code));
CCDirector::sharedDirector()->getRunningScene()->addChild(layer);
}
return;
}
//刷新头部金币
{
int gold = 0;
WuPin* wp = WuPinManager::getManager()->getWuPin(ItemsType_Gold);
if (wp != NULL)
{
gold = wp->getCount();
}
BaseSprite* header = MainLayerBase::getCurrentMainBase()->getHeader()->getHeaderContent();
CCLabelTTF* lable = (CCLabelTTF*)header->getChildByTag(STORE_FRAM_TAG_HEAD_JINBI);
char str[64];
sprintf(str, "%d", gold);
lable->setString(str);
}
ShenBingShangDianDuanZao *layer = new ShenBingShangDianDuanZao(data->equips);
CCDirector::sharedDirector()->getRunningScene()->addChild(layer, 1000);
layer->release();
}
示例13: CCSizeMake
// 06-15 11:43:50.179: D/cocos2d-x debug info(1716): Get data from file(tabulation_armor_helmet_1.png) failed!
MainLayerZhuangBeiBaseBody::MainLayerZhuangBeiBaseBody(ZhuangbeiXiangQingFrom from)
{
mFrom = from;
mTableView = CCTableView::create(this, CCSizeMake(624,678));
addChild(mTableView);
mTableView->setDirection(kCCScrollViewDirectionVertical);
mTableView->setVerticalFillOrder(kCCTableViewFillTopDown);
mTableView->setPosition(ccp(8,74));
mTableView->setDelegate(this);
mFooterForPop = NULL;
mClickedIdx = 0;
BaseSprite *bar = BaseSprite::create("mianban_zhuangbeishuliang_bg.png");
addChild(bar, 10);
bar->setPosition(ccp(320, 43));
CCString temp;
temp.initWithFormat("%s: %d/%u", LFStrings::getValue("zhuangbei").c_str()
, MyselfManager::getManager()->getAllEquipmentsWithOutEquipedOrChuanQi().size(), MAX_COUNTS_IN_KNAPSACK);
m_zbTotalLabel = CCLabelTTF::create(temp.getCString(), fontStr_kaiti, 20);
m_zbTotalLabel->setAnchorPoint(ccp(1, 0.5));
m_zbTotalLabel->setPosition(ccp(bar->getContentSize().width-20, bar->getContentSize().height/2));
bar->addChild(m_zbTotalLabel);
//分解提示
m_zbFenJieTiShi = CCLabelTTF::create(LFStrings::getValue("ZBCountMax_GanKuaiQuFenJieBa").c_str(), fontStr_kaiti, 20);
bar->addChild(m_zbFenJieTiShi);
m_zbFenJieTiShi->setPosition(ccp(bar->getContentSize().width/2, bar->getContentSize().height/2));
m_zbFenJieTiShi->setColor(fonColor_JingGao);
m_zbFenJieTiShi->setVisible(false);
m_zbFenJieMenu = CCMenu::create();
bar->addChild(m_zbFenJieMenu);
m_zbFenJieMenu->setPosition(ccp(0,0));
m_zbFenJieMenu->setVisible(false);
CCMenuItemImage *fenjie = CCMenuItemImage::create(
"mianban_zhuangbei_qufenjie.png",
"mianban_zhuangbei_qufenjie_select.png",
this, menu_selector(MainLayerZhuangBeiBaseBody::menuitemClicked_GotoFenJie));
m_zbFenJieMenu->addChild(fenjie);
fenjie->setPosition(ccp(m_zbTotalLabel->getPositionX()-fenjie->getContentSize().width/2, m_zbTotalLabel->getPositionY()));
if (mFrom != From_ZhuangBeiList)
{
m_zbFenJieMenu->removeFromParent();
}
}
示例14: menuItemClicked_choseHero
void MainLayerHerosBaseBody::menuItemClicked_choseHero(CCObject* pSender)
{
BaseSprite* bg = (BaseSprite*)((CCMenuItemImage*)pSender)->getParent()->getParent();
CCTableViewCell* cell = (CCTableViewCell*)bg->getParent();
int idx = cell->getIdx();
if(mChoseHeroState[idx]>=1 && mChoseHeroState[idx]<=4)
{
mChoseHeroState[idx] = 0;
--mChoseNum;
// mTableView->reloadData();
for(int i=0; i!=mHerosVec.size(); ++i)
mTableView->updateCellAtIndex(i);
}
else if(mChoseHeroState[idx] == 0 && mChoseNum<3)
{
int temp[4] = {false};
int chessboard;
for(int i=0; i!=mChoseHeroState.size(); ++i)
if(mChoseHeroState[i]>=1 && mChoseHeroState[i]<=4)
temp[mChoseHeroState[i]-1] = true;
for(int i=0; i!=4; ++i)
if(! temp[i])
{
if(MyselfManager::getManager()->getMyZhuJueData()->getChessBoardPos() == i+1)
continue;
chessboard = i+1;
break;
}
mChoseHeroState[idx] = chessboard;
++mChoseNum;
// mTableView->reloadData();
for(int i=0; i!=mHerosVec.size(); ++i)
mTableView->updateCellAtIndex(i);
}
}
示例15: getNewMessageInfo
void MainFooterLayer::getNewMessageInfo(CCNode* pInfoStr)
{
if (pInfoStr)
{
pInfoStr->removeFromParent();
}
BaseSprite *messageBar = (BaseSprite*)this->getChildByTag(Tag_MessageInfoBar);
if (messageBar)
{
NetLabelTTF* pLable = (NetLabelTTF*)messageBar->getChildByTag(Tag_MessageTipStr);
if (!pLable)
{
if (SystemPushMessagePool::getPool()->getCurMsgCount() < 1)
{
messageBar->removeFromParent();
}
else
{
MarqueeMessage info;
if (SystemPushMessagePool::getPool()->getOneMessage(info))
{
showMessageBar(info);
}
}
}
}
else
{
MarqueeMessage info;
// info.uid=186384394;
// info.type = 5;
// info.count=1;
// sprintf(info.subject, "%s", "assdf");
if (SystemPushMessagePool::getPool()->getOneMessage(info))
{
showMessageBar(info);
}
}
}