本文整理汇总了C++中CCSprite::displayFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ CCSprite::displayFrame方法的具体用法?C++ CCSprite::displayFrame怎么用?C++ CCSprite::displayFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCSprite
的用法示例。
在下文中一共展示了CCSprite::displayFrame方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateSpCell
//滑动更新cell
void SGSpecialBattleSecionCell::updateSpCell(SpecialBattleSecData *cellData)
{
if (!cellData)
{
return ;
}
this->cellData = cellData;
//更新节名称
sectionName->setString(cellData->sectionName.c_str());
//战字按钮显示与否
battleBtn->setVisible(cellData->canJoin);
battleBtn->setEnabled(cellData->canJoin);
//条件
if (cellData->canJoin)
{
int suggestPower = cellData->suggestPower;
openCondition->setString(CCString::createWithFormat(str_SpecialBattleSuggestPower, suggestPower)->getCString());
}
else
{
openCondition->setString(cellData->conditionTips.c_str());
}
//底图改变
int iconId = cellData->bgIconId;
SGMainManager::shareMain()->addSpHeadBgPlistByNum(iconId, sg_specialBattleSecionLayer);
CCSprite *newBg = CCSprite::createWithSpriteFrameName(CCString::createWithFormat("sphead%d.png", iconId)->getCString());
bgButton->setFontImage(newBg->displayFrame());
greyMask->setVisible(!cellData->canJoin);
}
示例2: memset
void SGGetSalaryLayer::updateTime1()
{
int m = nowTime1;
int secs = m % 60;
m /= 60;
int minutes = m % 60;
m /= 60;
int hours = m%24;
int days = m/24;
char timeStr[32];
memset(timeStr, 0, 32);
snprintf(timeStr, 32, str_GetSalaryLayer_str2, days,hours, minutes, secs);
if (nowTime1 == 0&&isShowPvP)
{
btn1->setImage("store_lank.png");
CCSprite *font = CCSprite::createWithSpriteFrameName("reward_font_lingqu.png");
btn1->setFontImage(font->displayFrame());
lab_iscanget1->setString(str_GetSalaryLayer_str8);
if (btn->isVisible()) {
btn1->setEnabled(true);
}
return;
}
nowTime1--;
lab_iscanget1->setString(timeStr);
}
示例3: memset
void SGVisitItem1::updateTime()
{
// CCSpriteFrameCache::sharedSpriteFrameCache() -> addSpriteFramesWithFile("sgvisitlayer/sgvisitlayer1.plist");
int m = officerTime;
int secs = m % 60;
m /= 60;
int minutes = m % 60;
int hours = m / 60;
char timeStr[32];
memset(timeStr, 0, 32);
snprintf(timeStr, 32, "%02d:%02d:%02d", hours, minutes, secs);
if (officerTime == 0)
{
time->setString(timeStr);
// officerTime = 30;
// this->unschedule(schedule_selector(SGVisitItem1::updateTime));
CCSprite *sprte = CCSprite::createWithSpriteFrameName("visit_free.png");
visit1->setFontImage(sprte->displayFrame());
m_noticeGoldFree->setVisible(true);
return;
}
officerTime--;
time->setString(timeStr);
}
示例4: startWithTarget
void GAnimate::startWithTarget(CCNode *pTarget)
{
if (m_bFirstTick) CCFiniteTimeAction::startWithTarget(pTarget);
else CCActionInterval::startWithTarget(pTarget);
CCSprite *pSprite = (CCSprite*)(pTarget);
CC_SAFE_RELEASE(m_pOrigFrame);
if (this->getAnimation()->getRestoreOriginalFrame())
{
m_pOrigFrame = pSprite->displayFrame();
m_pOrigFrame->retain();
}
if (m_bFirstTick) m_nNextFrame = 0;
m_uExecutedLoops = 0;
m_bFirstTick = false;
}
示例5: sharedSpriteFrameCache
CCSpriteFrame *SpriteUtil::GetFrame(const char *frame_name) {
#ifdef SPRITEUTIL_DEBUG_MODE
if (is_use_plist) {
CCSpriteFrame *frame =
CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(frame_name);
if (frame == NULL) {
CCLog("GetFrameInPlist___%s == NUL", frame_name);
}
return frame;
}
#else
if (is_use_plist) {
return CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(frame_name);
}
#endif
/**** 单个文件方式 ****/
CCSprite *sp = CCSprite::create(frame_name);
if (sp == NULL) {
CCLog("___GetFrame: %s NUL", frame_name);
}
return sp->displayFrame();
}
示例6: salaryEnterListener
void SGGetSalaryLayer::salaryEnterListener(cocos2d::CCObject *obj)
{
ResourceManager::sharedInstance()->bindTexture("sgrewardlayer/sgrewardlayer.plist", RES_TYPE_LAYER_UI, sg_getsalaryLayer);
SGSocketRequest *sr = (SGSocketRequest *)obj;
main::RewardSalaryEntryResponse *response = (main::RewardSalaryEntryResponse *)sr->m_msg;
nowTime = response->levelrewardtime();
nowTime1 = response->pvprewardtime();
if (nowTime!=0 && nowTime1!= 0 ) {
// CCString *str = (CCString *)SGPlayerInfo::sharePlayerInfo()->getrewardNotice()->objectAtIndex(3);
// str->setString(CCString::createWithFormat("%d",0)->getCString());
CCArray *array = SGPlayerInfo::sharePlayerInfo()->getrewardNotice();
int nsum = array->count();
for (int i = 0 ;i < nsum ;i++) {
SGRewardNoticeItem * item =(SGRewardNoticeItem *) array->objectAtIndex(i);
if(item->gettypeItem()==Reward_Salary)
{
item->setstateItem(0);
break;
}
}
}
if (nowTime!=0 && nowTime1== 0 && response->pvplevel() == 0) {
// CCString *str = (CCString *)SGPlayerInfo::sharePlayerInfo()->getrewardNotice()->objectAtIndex(3);
// str->setString(CCString::createWithFormat("%d",0)->getCString());
CCArray *array = SGPlayerInfo::sharePlayerInfo()->getrewardNotice();
int nsum = array->count();
for (int i = 0 ;i < nsum ;i++) {
SGRewardNoticeItem * item =(SGRewardNoticeItem *) array->objectAtIndex(i);
if(item->gettypeItem()==Reward_Salary)
{
item->setstateItem(0);
break;
}
}
}
if (nowTime1 != 0)
{
btn1->setImage("store_huik.png");
CCSprite *font = CCSprite::createWithSpriteFrameName("reward_font_yiling.png");
btn1->setFontImage(font->displayFrame());
//modify by:zyc. 服务器已经更改背包数据 客户端无需操作。
//SGPlayerInfo::sharePlayerInfo()->setPlayerCoins(SGPlayerInfo::sharePlayerInfo()->getPlayerCoins() + response->pvplevelcoin());
EFFECT_PLAY(MUSIC_34);
// SGMainManager::shareMain()->showMessage(CCString::createWithFormat("成功领取了%d",response->pvplevelcoin())->getCString());
if ( m_type == 1 && response->pvplevelcoin() > 0 )
{
//弹出框显示奖励
CCArray *data=CCArray::create();
data->retain();
SGMailSystemAccessoryDataModel *datamodel=new SGMailSystemAccessoryDataModel ;
datamodel->setType(1);
datamodel->setCount(response->pvplevelcoin());
data->addObject(datamodel);
SGShowRewardBox *rewardBox=SGShowRewardBox::create(this, data);
SGMainManager::shareMain()->showBox(rewardBox);
}
btn1->setEnabled(false);
}
if (nowTime != 0)
{
btn->setImage("store_huik.png");
CCSprite *font = CCSprite::createWithSpriteFrameName("reward_font_yiling.png");
btn->setFontImage(font->displayFrame());
//modify by:zyc. 服务器已经更改背包数据 客户端无需操作。
//SGPlayerInfo::sharePlayerInfo()->setPlayerCoins(SGPlayerInfo::sharePlayerInfo()->getPlayerCoins() + response->levelcoin());
EFFECT_PLAY(MUSIC_34);
// SGMainManager::shareMain()->showMessage(CCString::createWithFormat("成功领取了%d",response->levelcoin())->getCString());
if (m_type == 0 &&response->levelcoin() > 0)
{
//弹出框显示奖励
CCArray *data=CCArray::create();
data->retain();
SGMailSystemAccessoryDataModel *datamodel=new SGMailSystemAccessoryDataModel ;
datamodel->setType(1);
datamodel->setCount(response->levelcoin());
data->addObject(datamodel);
SGShowRewardBox *rewardBox=SGShowRewardBox::create(this, data);
SGMainManager::shareMain()->showBox(rewardBox);
}
btn->setEnabled(false);
}
SGMainManager::shareMain()->updataUserMsg();
}
示例7: refreshView
void SGEquipStrengLayer::refreshView(SGEquipCard *card)
{
_card = card;
SGEquipmentDataModel *temp = SGStaticDataManager::shareStatic()->getEquipById(_card->getItemId());
SGMainManager::shareMain()->addEquipPng(temp->getIconId(),sg_equipstrengLayer);
CCString *str = CCString::createWithFormat("equip%d.png",temp->getIconId());
CCSprite *item = CCSprite::createWithSpriteFrameName(str->getCString());
static_cast<CCSprite *>(this->getChildByTag(123))->setDisplayFrame(item->displayFrame());
this->setstar(_card->getCurrStar(),_card->getUpgradestar());
SGEquipmentDataModel *general = SGStaticDataManager::shareStatic()->getEquipById(_card->getItemId());
this->setCardType(general->getEquipType());
equipName->setString(_card->getOfficerName()->getCString());
int equipStar = _card->getCurrStar() - 2;
equipStar = equipStar < 0 ? 0 : equipStar;
if (equipStar >= 0 && equipStar < 5)
{
equipName->setInsideColor(ccStarLevelColor[equipStar]);
}
else
{
equipName->setInsideColor(ccWHITE);
}
equiplevel->setString(CCString::createWithFormat("Lv %d/%d",_card->getCurrLevel(), SGPlayerInfo::sharePlayerInfo()->getPlayerLevel())->getCString());
setEquipLevel(_card->getCurrLevel());
setCostCount(_card->getCurrLevel());
setCurrStatus(_card->getCurrLevel());
creatBostLevel(SGLayout::getPoint(kMiddleCenter));
showMainChat(false);
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
//更换背景图片
//创建4中颜色武将背景
std::vector<std::string> str_vec;
if(winSize.height != 1136)
{
str_vec.push_back("greenBg.png");
str_vec.push_back("blueBg.png");
str_vec.push_back("purpleBg.png");
str_vec.push_back("orangeBg.png");
}
//inphone 5 根据武将地图来
else
{
str_vec.push_back("greenBgI5.png");
str_vec.push_back("blueBgI5.png");
str_vec.push_back("purpleBgI5.png");
str_vec.push_back("orangeBgI5.png");
}
int starLev = _card->getCurrStar();
starLev = starLev<3?3:starLev;
starLev = starLev>6?6:starLev;
//光效背景图片
CCSprite * refreshBg = CCSprite::createWithSpriteFrameName(str_vec[starLev-3].c_str());
((CCSprite*)getChildByTag(1919))->setDisplayFrame(refreshBg->displayFrame());
}
示例8: getContentSize
//=============================================================
//=============================================================
void CC3DCircleListLayer::initDataCircle(float fEllipseA,float fEllipseB,CCSize itemSize,CCArray* pArray,bool bFlipY)
{
if(!pArray)
return;
m_itemSize = itemSize;
m_fEllipseA = fEllipseA;
m_fEllipseB = fEllipseB;
int nAllItemCount = pArray->count();
float fCircleStepDegree = (2*M_PI)/nAllItemCount;
float fMoveX = getContentSize().width*0.5;
float fMoveY = getContentSize().height*0.5;
m_pButtonArray->removeAllObjects();
for(int i=0;i<nAllItemCount;i++)
{
float fCurDegree = fCircleStepDegree * (i+1);
float fCircleX = m_fEllipseA * cosf(fCurDegree);
float fCircleY = m_fEllipseB * sinf(fCurDegree);
fCircleX += fMoveX;
fCircleY += fMoveY;
CCSprite* pSprite = (CCSprite*)pArray->objectAtIndex(i);
CCScale9Sprite* pScaleSprite = CCScale9Sprite::createWithSpriteFrame(pSprite->displayFrame());
CCButton* pButton = CCButton::create( pScaleSprite);
pButton->setTag(i);
pButton->setZoomOnTouchDown(false);
CCPoint point = ccp(fCircleX,fCircleY);
pButton->setPosition(point);
CCString* pString = new CCString();
pString->initWithFormat("%f",fCurDegree);
pButton->setUserData(pString);
pButton->addTargetWithActionForControlEvents(this, cccontrol_selector(CC3DCircleListLayer::clickButton), CCControlEventTouchUpInside);
addChild(pButton);
m_pButtonArray->addObject(pButton);
if(bFlipY)
{
CCSize buttonSize = pButton->getContentSize();
CCSprite* pFlipYSprite = CCSprite::createWithTexture(pSprite->getTexture());
CCRect oldRect = pSprite->getTextureRect();
pFlipYSprite->setFlipY(true);
pFlipYSprite->setOpacity(255*0.5);
pFlipYSprite->setAnchorPoint(ccp(0.5,1));
pFlipYSprite->setPosition(ccp(buttonSize.width*0.5,0));
pButton->addChild(pFlipYSprite);
}
// CCSize buttonSize = pButton->getContentSize();
// char testChr[32];
// sprintf(testChr, "%d",i);
// CCLabelTTF* pTestLabel = CCLabelTTF::create(testChr, "Arial", 52);
// pTestLabel->setColor(ccRED);
// pTestLabel->setPosition(ccp(buttonSize.width*0.5,buttonSize.height*0.5));
// pButton->addChild(pTestLabel);
}
refreshItemWithMoveDegree(0);
}
示例9: if
//.........这里部分代码省略.........
SGButton *visit10 = SGButton::create("visit_anniu.png", "font_tfz1.png", this, menu_selector(SGVisitItem1::confirmHandler),CCPointZero,false,true);
visit10->setTag(num +120);
visit10->setAnchorPoint(ccp(1, 1));
visit10->ignoreAnchorPointForPosition(false);
visit1->setAnchorPoint(ccp(1, 1));
visit1->ignoreAnchorPointForPosition(false);
visit1->setPosition(ccpAdd(font2->getPosition(), ccp(visit10->getContentSize().width / 1.8, -font2->getContentSize().height / 1.9 + shift)));
visit10->setPosition(ccpAdd(visit1->getPosition(), ccp(visit10->getContentSize().width * 1.2, 0)));
CCMenu *menu1 = CCMenu::create();
menu1->setTouchPriority(128);
menu1->setTag(111);
menu1->setPosition(CCPointZero);
this->addChild(menu1,5);
menu1->addChild(visit1);
menu1->addChild(visit10);
//买物品送武将
SGCCLabelTTF *infoTips = SGCCLabelTTF::create("赠送奖励:武将或者物品", FONT_PANGWA, 30);
this->addChild(infoTips, 8);
infoTips->setPosition(ccpAdd(ccp(CCDirector::sharedDirector()->getWinSize().width / 2, CCDirector::sharedDirector()->getWinSize().height / 2),
ccp(0, visit10->getPositionY())));
//有免费元宝探访机会
m_noticeGoldFree = CCSprite::createWithSpriteFrameName("publc_notice.png");
m_noticeGoldFree->setPosition(ccp(visit1->getContentSize().width*0.92 , visit1->getContentSize().height*0.92));
m_noticeGoldFree->setVisible(false);
visit1->addChild(m_noticeGoldFree);
if (officerTime == 0)
{
CCSprite *sprte = CCSprite::createWithSpriteFrameName("visit_free.png");
visit1->setFontImage(sprte->displayFrame());
m_noticeGoldFree->setVisible(true);
}
// if(STATE_YES == SGPlayerInfo::sharePlayerInfo()->getPlayerNoticeById(401 , false))
currTime = a;
//left->setPercentage(b);
int secs = currTime % 60;
currTime /= 60;
int minutes = currTime % 60;
int hours = currTime / 60;
char timeStr[32];
memset(timeStr, 0, 32);
snprintf(timeStr, 32, "%02d:%02d:%02d", hours, minutes, secs);
SGCCLabelTTF *timeMsg = SGCCLabelTTF::create(str_TongQueLayer_str21, FONT_PANGWA, FONTSIZE(13));
this->addChild(timeMsg,10);
timeMsg->setPosition(ccpAdd(zik->getPosition(), ccp(zik->getContentSize().width / 2.4 +timeShiftx, -timeMsg->getContentSize().height + timeShift)));
time = SGCCLabelTTF::create(timeStr, FONT_PANGWA, FONTSIZE(13));
this->addChild(time,10);
time->setPosition(ccpAdd(timeMsg->getPosition(), ccp(-timeMsg->getContentSize().width / 1.8 - time->getContentSize().width / 2, 0)));
CCSize size=CCDirector::sharedDirector()->getWinSize();
ResourceManager::sharedInstance()->bindTexture("sanguobigpic/wj_6.1.plist",RES_TYPE_LAYER_UI ,sg_visitShowCard);
ResourceManager::sharedInstance()->bindTexture("sanguobigpic/wj_6.2.plist",RES_TYPE_LAYER_UI ,sg_visitShowCard);
ResourceManager::sharedInstance()->bindTexture("sanguobigpic/wj_6.3.plist",RES_TYPE_LAYER_UI ,sg_visitShowCard);
ResourceManager::sharedInstance()->bindTexture("sanguobigpic/wj_6.4.plist",RES_TYPE_LAYER_UI ,sg_visitShowCard);
ResourceManager::sharedInstance()->bindTexture("sanguobigpic/wj_6.5.plist",RES_TYPE_LAYER_UI ,sg_visitShowCard);
示例10: updatePiecesCard
//滑动时更新cell
void SGPiecesCell::updatePiecesCard(SGPiecesCard *card)
{
ResourceManager::sharedInstance()->bindTexture("sgpieceslayer/sgpieceslayer.plist", RES_TYPE_LAYER_UI, sg_piecesLayer);
char officerName[256] = "\0";
int shift = 0;// 名称黑色背景右向偏移
int iconId = -1;
if (card->getItemType() == 0)//武将
{
SGOfficerDataModel *temp = SGStaticDataManager::shareStatic()->getOfficerById(card->getCallCardId());
iconId = temp->getIconId();
}
else if (card->getItemType() == 1)//装备
{
SGEquipmentDataModel *temp =SGStaticDataManager::shareStatic()->getEquipById(card->getCallCardId());
iconId = temp->getIconId();
}
SGMainManager::shareMain()->addHeadIconPlistByNum(iconId,sg_piecesLayer);
sprintf(officerName, "head%d.png", iconId);
shift = 10;
//滑动过后重置cell上的头像
CCSprite *piecesHeadTemp = CCSprite::createWithSpriteFrameName(officerName);
static_cast<CCSprite *>(this->getChildByTag(HEAD_TAG))->setDisplayFrame(piecesHeadTemp->displayFrame());
//滑动过后的品质框
char pinzhi[256] = "\0";
if (card->getItemType() == 0)
{
SGOfficerDataModel *temp = SGStaticDataManager::shareStatic()->getOfficerById(card->getCallCardId());
int starlvl = temp->getOfficerCurrStarLevel();
if (starlvl>1)
{
starlvl-=1;
}
sprintf(pinzhi, "officerPinzhi_%d_0.png",starlvl);
}
else if (card->getItemType() == 1)
{
SGEquipmentDataModel *equipModel = SGStaticDataManager::shareStatic()->getEquipById(info->getCallCardId());
sprintf(pinzhi, "equipPinzhi_%d_0.png", equipModel->getEquipStarPinzhi());
}
//更新的时候重围品质框
CCSprite *pzTemp = CCSprite::createWithSpriteFrameName(pinzhi);
static_cast<CCSprite *>(this->getChildByTag(PINZHI_TAG))->setDisplayFrame(pzTemp->displayFrame());
//头像蒙版不需要更新
int addCommonPieces = 0;//加到当前碎片数上,值由isUseCommon来决定是0,还是可使用的通用碎片数
int piecesCommonNum = 0;
CCArray *piecesArray = SGPlayerInfo::sharePlayerInfo()->getPiecesCommonCards();
if (piecesArray->data && piecesArray->data->arr && piecesArray->count())
{
piecesCommonNum = ((SGPiecesCard *)piecesArray->objectAtIndex(0))->getPiecesCurNum();//能使用的通用碎片
}
//重置碎片名称
piecesName->setString(card->getPiecesName()->getCString());
//更新显示进度
totalAndCurProgress->setString(CCString::createWithFormat(str_PiecesCell_str4, card->getPiecesCurNum())->getCString());
// if (card->getPiecesCurNum() >= card->getSummonNeed())//拥有的碎片数能召唤
// {
// totalAndCurProgress->setInsideColor(COLOR_GREEN);
// }
// else
// {
// totalAndCurProgress->setInsideColor(ccWHITE);
// }
}