本文整理汇总了C++中CCDictionary::allKeys方法的典型用法代码示例。如果您正苦于以下问题:C++ CCDictionary::allKeys方法的具体用法?C++ CCDictionary::allKeys怎么用?C++ CCDictionary::allKeys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCDictionary
的用法示例。
在下文中一共展示了CCDictionary::allKeys方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initWithDictionary
bool GHAnimationFrame::initWithDictionary(CCDictionary* dict)
{
if(NULL == dict)return false;
CCDictionary* notifsInfo = (CCDictionary*)dict->objectForKey("notification");
// CGPoint point = [dict objectForKey:@"offset"];//currently not used
CCString* spriteFrameName = (CCString*)dict->objectForKey("spriteframe");
if(spriteFrameName)
{
m_spriteFrame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(spriteFrameName->getCString());
#if COCOS2D_DEBUG > 0
char msg[256] = {0};
sprintf(msg, "SpriteFrame %s was not found. Use CCSpriteFrameCache to load spriteFrames before loading an animation.", spriteFrameName->getCString());
CCAssert(m_spriteFrame != NULL, msg);
#endif
m_spriteFrame->retain();
}
if(notifsInfo != NULL && notifsInfo->allKeys() && notifsInfo->allKeys()->count() > 0)
{
m_userInfo = CCDictionary::createWithDictionary(notifsInfo);
m_userInfo->retain();
}
return true;
}
示例2: refreshList
void RequestList::refreshList()
{
this->unscheduleUpdate();
if (_fbIncomingRequestList != NULL)
{
_fbIncomingRequestList->release();
}
_fbIncomingRequestList = NULL;
_fbIncomingRequestList = CCArray::create();
_fbIncomingRequestList->retain();
CCDictionary* completedDictionary = EziFBIncomingRequestManager::sharedManager()->getCompletedRequest();
if (completedDictionary)
{
CCArray* completedKeys = completedDictionary->allKeys();
if (completedKeys)
{
for (int i=0; i<completedKeys->count(); i++)
{
CCString *cKey = (CCString*)completedKeys->objectAtIndex(i);
_fbIncomingRequestList->addObject(completedDictionary->objectForKey(cKey->getCString()));
}
}
}
CCDictionary* pendingDictionary = EziFBIncomingRequestManager::sharedManager()->getPendingRequests();
if (pendingDictionary)
{
CCArray* pendingKeys = pendingDictionary->allKeys();
if (pendingKeys)
{
for (int i=0; i<pendingKeys->count(); i++)
{
CCString *pKey = (CCString*)pendingKeys->objectAtIndex(i);
_fbIncomingRequestList->addObject(pendingDictionary->objectForKey(pKey->getCString()));
}
}
}
mPhotoLoadIndex = this->numberOfCellsInTableView(mTableView);
mReadyForNextDownload = true;
this->scheduleUpdate();
}
示例3: initWithMap
void ScoreCenter::initWithMap(int mapNo)
{
CCString* mapNoStr = CCString::createWithFormat("map%02d.plist", mapNo);
CCDictionary* pdict = CCDictionary::createWithContentsOfFile(mapNoStr->getCString());
CCString* moveLimit = (CCString*)pdict->objectForKey("moveLimit");
CCString* timeLimit = (CCString*)pdict->objectForKey("timeLimit");
CCString* colorNum = (CCString*)pdict->objectForKey("colorNum");
CCString* gameMode = (CCString*)pdict->objectForKey("gameMode");
CCString* taskMode = (CCString*)pdict->objectForKey("taskMode");
CCString* thingMode = (CCString*)pdict->objectForKey("dropMode");
CCDictionary* scoreTarget = (CCDictionary*)pdict->objectForKey("scoreTarget");
CCString* star1 = (CCString*)scoreTarget->objectForKey("star1");
CCString* star2 = (CCString*)scoreTarget->objectForKey("star2");
CCString* star3 = (CCString*)scoreTarget->objectForKey("star3");
CCDictionary* taskThings = (CCDictionary*)pdict->objectForKey("taskDrops");
CCString* bornThingMove = (CCString*)pdict->objectForKey("bornDropMove");
CCString* thingBornX = (CCString*)pdict->objectForKey("dropBornX");
CCString* thingBornY = (CCString*)pdict->objectForKey("dropBornY");
if(moveLimit) this->setMoveLimit(moveLimit->intValue());
if(timeLimit) this->setTimeLimit(timeLimit->intValue());
if(colorNum) this->setColorNum(colorNum->intValue());
if(gameMode) this->setGameMode((TypeGameMode)gameMode->intValue());
if(taskMode) this->setTaskMode((TypeTaskMode)taskMode->intValue());
if(thingMode) this->setDropMode((TypeDropMode)thingMode->intValue());
if (taskThings) {
// task things pair type-number
CCArray* thingsArr = taskThings->allKeys();
if (thingsArr->count()>0) {
CCArray* thingTypes = CCArray::createWithCapacity(thingsArr->count());
CCArray* thingNums = CCArray::createWithCapacity(thingsArr->count());
for (int i=0; i < thingsArr->count(); i++) {
CCString* key = (CCString*)thingsArr->objectAtIndex(i);
thingTypes->addObject(key);
thingNums->addObject(taskThings->objectForKey(key->getCString()));
}
this->setDropTypes(thingTypes);
this->setDropNums(thingNums);
}
}
if(bornThingMove) this->setBornDropMove(bornThingMove->intValue());
if (thingBornX) this->setDropBornX(ResUtil::componentsSeparatedByString(thingBornX, "|"));
if (thingBornY) this->setDropBornY(ResUtil::componentsSeparatedByString(thingBornY, "|"));
this->setScoreTarget1(star1->intValue());
this->setScoreTarget2(star2->intValue());
this->setScoreTarget3(star3->intValue());
this->setIsAsynMark(true);
this->m_initUI();
}
示例4: simulateAnswerRight
void QuestionLayer::simulateAnswerRight()
{
this->unschedule(schedule_selector(QuestionLayer::timerCB));
CCDictionary* results = questionObj->rightAnswer;
for (int i=0; i<results->allKeys()->count(); i++) {
CCString* key = (CCString *)(results->allKeys()->objectAtIndex(i));
results->setObject(CCString::createWithFormat("%d", 1), key->getCString());
}
//回答完成所有正确答案
for (int i=0; i<results->allKeys()->count(); i++) {
CCString* key = (CCString *)(results->allKeys()->objectAtIndex(i));
CCControlButton* btn = (CCControlButton *)(this->getChildByTag(key->intValue()));
CCSprite* spr = CCSprite::create("star000.png");
spr->setAnchorPoint(ccp(0.5f, 0.5f));
spr->setPosition(ccp(btn->getContentSize().width/2, btn->getContentSize().height/2));
btn->addChild(spr);
CCBlink* blink = CCBlink::create(1.0f, 3);
if (i < results->allKeys()->count()-1) {
spr->runAction(blink);
} else {
CCAction* pAction = CCCallFuncND::create(this, callfuncND_selector(QuestionLayer::noticeDelegate), NULL);
spr->runAction(CCSequence::create(blink, pAction, NULL));
}
}
rightAnswer++;
if (timerCount >= timerTotal*2/3) {
rightLimit += 1;
//播放快速答题音效
GameSoundManager::shareManager()->playAnswerCool();
} else {
//播放普通答题正确音效
GameSoundManager::shareManager()->playAnswerRight();
}
isAnswerFinished = true;
}
示例5: GetJsonFromCCObject
json_t* NDKHelper::GetJsonFromCCObject(CCObject* obj)
{
if (dynamic_cast<CCDictionary*>(obj))
{
CCDictionary *mainDict = (CCDictionary*)obj;
CCArray *allKeys = mainDict->allKeys();
json_t* jsonDict = json_object();
if(allKeys == NULL ) return jsonDict;
for (unsigned int i = 0; i < allKeys->count(); i++)
{
const char *key = ((CCString*)allKeys->objectAtIndex(i))->getCString();
json_object_set_new(jsonDict,
key,
NDKHelper::GetJsonFromCCObject(mainDict->objectForKey(key)));
}
return jsonDict;
}
else if (dynamic_cast<CCArray*>(obj))
{
CCArray* mainArray = (CCArray*)obj;
json_t* jsonArray = json_array();
for (unsigned int i = 0; i < mainArray->count(); i++)
{
json_array_append_new(jsonArray,
NDKHelper::GetJsonFromCCObject(mainArray->objectAtIndex(i)));
}
return jsonArray;
}
else if (dynamic_cast<CCString*>(obj))
{
CCString* mainString = (CCString*)obj;
json_t* jsonString = json_string(mainString->getCString());
return jsonString;
}
else if(dynamic_cast<CCInteger*>(obj))
{
CCInteger *mainInteger = (CCInteger*) obj;
json_t* jsonString = json_integer(mainInteger->getValue());
return jsonString;
}
return NULL;
}
示例6: getJsonString
std::string CJLMSUtil::getJsonString(cocos2d::CCArray* v_list, std::string strKey)
{
std::string ret = CCString::createWithFormat("{\"%s\":[", strKey.c_str())->getCString();
std::string valueFormat = "\"[__key__]\":\"[__value__]\"";
for(int arrIdx=0; arrIdx<v_list->count(); arrIdx++)
{
ret.append("{");
CCDictionary *item = (CCDictionary *)v_list->objectAtIndex(arrIdx);
CCArray* keyArray = item->allKeys();
for (int var = 0; var < v_list->count(); var++) {
std::string key = ((CCString *)keyArray->objectAtIndex(var))->m_sString;
std::string value = ((CCString *)item->valueForKey(key))->m_sString;
std::string rowString = valueFormat;
rowString = THStringUtil::replaceAll(
THStringUtil::replaceAll(
rowString,
"[__key__]",
key
),
"[__value__]",
value
);
if (var < v_list->count() - 1)
rowString.append(",");
ret.append(rowString);
}
if(arrIdx+1<v_list->count())
{
ret.append("},");
}
else
{
ret.append("}");
}
}
ret.append("]}");
return ret;
}
示例7: initView
void SGCardsLayer::initView(CCArray *array)
{
ResourceManager::sharedInstance()->bindTexture("sgcardslayer/sgcardslayer.plist", RES_TYPE_LAYER_UI, sg_cardsLayer);
ResourceManager::sharedInstance()->bindTexture("soldier/soldier3101-1-3303-3.plist", RES_TYPE_LAYER_UI, sg_cardsLayer);
ResourceManager::sharedInstance()->bindTexture("sggeneralinfolayer/sggeneralinfolayer1.plist", RES_TYPE_LAYER_UI, sg_cardsLayer);
ResourceManager::sharedInstance()->bindTexture("sgstrenglayer/sgstrenglayer.plist", RES_TYPE_LAYER_UI, sg_cardsLayer, LIM_PNG_AS_PNG);
tableViewHeight = 145;
tableViewColumns = 5;
float headhgt = SGMainManager::shareMain()->getTotleHdHgt();
float btmhgt = SGMainManager::shareMain()->getBottomHeight();
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCSprite *title_bg = CCSprite::createWithSpriteFrameName("title_bg.png");
title_bg->setAnchorPoint(ccp(0.5, 1));
title_bg->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(0, -headhgt + title_bg->getContentSize().height-2)));
this->addChild(title_bg,-1);
CCSprite *titlecenter = CCSprite::createWithSpriteFrameName("title_bg_2.png");
titlecenter->setAnchorPoint(ccp(0.5, 0));
titlecenter->setPosition(ccpAdd(title_bg->getPosition(), ccp(0, - title_bg->getContentSize().height -10)));
this->addChild(titlecenter,10);
titlecenter->setScaleX(4);
CCSprite *title_bg_l = CCSprite::createWithSpriteFrameName("title_bg_LR.png");
title_bg_l->setAnchorPoint(ccp(0, 0));
title_bg_l->setPosition(ccpAdd(title_bg->getPosition(), ccp(-s.width/2, - title_bg->getContentSize().height -10)));
this->addChild(title_bg_l,10);
CCSprite *title_bg_r = CCSprite::createWithSpriteFrameName("title_bg_LR.png");
title_bg_r->setFlipX(true);
title_bg_r->setAnchorPoint(ccp(1, 0));
title_bg_r->setPosition(ccpAdd(title_bg->getPosition(), ccp(s.width/2, - title_bg->getContentSize().height -10)));
this->addChild(title_bg_r,10);
SGButton *backBtn = SGButton::createFromLocal("store_exchangebtnbg.png", str_back, this, menu_selector(SGCardsLayer::backHandler),CCPointZero,FONT_PANGWA,ccWHITE,32);
this->addBtn(backBtn);
backBtn->setPosition(ccp(backBtn->getContentSize().width*.55,title_bg->getPosition().y -title_bg->getContentSize().height*.5f));
SGCCLabelTTF *title = NULL;
datas = CCArray::create();
datas->retain();
_array = CCArray::create();
_array->retain();
if (enterType == 0 || enterType == 1 || enterType == 2 || enterType == 3) {
CCDictionary * dic = NULL;
switch (enterType) {
case 0:
{
title = SGCCLabelTTF::create(str_CardsLayer_str1, FONT_XINGKAI, 36 , COLOR_UNKNOW_TAN);
dic = SGStaticDataManager::shareStatic()->getWeiOfficerDict();
}
break;
case 1:
{
title = SGCCLabelTTF::create(str_CardsLayer_str2, FONT_XINGKAI, 36 , COLOR_UNKNOW_TAN);
dic = SGStaticDataManager::shareStatic()->getShuOfficerDict();
}
break;
case 2:
{
title = SGCCLabelTTF::create(str_CardsLayer_str3, FONT_XINGKAI, 36 , COLOR_UNKNOW_TAN);
dic = SGStaticDataManager::shareStatic()->getWuOfficerDict();
}
break;
case 3:
{
title = SGCCLabelTTF::create(str_CardsLayer_str4, FONT_XINGKAI, 36 , COLOR_UNKNOW_TAN);
dic = SGStaticDataManager::shareStatic()->getQunOfficerDict();
}
break;
case 4:
{
dic = SGStaticDataManager::shareStatic()->getEquipViewDict();
}
break;
}
for (int i = 0; i<dic->allKeys()->count(); i++) {
CCString *string = (CCString*)dic->allKeys()->objectAtIndex(i);
SGOfficerDataModel *oCard = SGStaticDataManager::shareStatic()->getOfficerById(string->intValue());
if (oCard)
{
int areId = ((CCString*)((CCDictionary *)dic->objectForKey(string->getCString()))->objectForKey("areaId"))->intValue();
SGOfficerCard *officerCard = new SGOfficerCard;
officerCard->setSsid(areId);//排序用
officerCard->setOfficerName(oCard->getOfficerName());
officerCard->setMaxLevel(oCard->getOfficerMaxLevel());
officerCard->setCurrExp(0);
officerCard->setCurrStar(oCard->getOfficerCurrStarLevel());
//.........这里部分代码省略.........
示例8: appendObject
void appendObject(Ref* obj, xml_node& node)
{
if(isKindOfClass(obj, CCDictionary))
{
//CCLOG("Dictionary recognized");
CCDictionary* dict = (CCDictionary*)obj;
xml_node children = node.append_child("dict");
CCArray* keys = dict->allKeys();
if(keys != NULL)
{
for(int i = 0; i < keys->count(); i++)
{
CCString* key = (CCString*)keys->objectAtIndex(i);
children.append_child("key").append_child(node_pcdata).set_value(key->getCString());
appendObject(dict->objectForKey(key->getCString()), children);
}
}
}
else if(isKindOfClass(obj, CCArray))
{
//CCLOG("Array recognized");
CCArray* array = (CCArray*)obj;
xml_node children = node.append_child("array");
for(int i = 0; i < array->count(); i++)
{
Ref* child = (Ref*)array->objectAtIndex(i);
appendObject(child, children);
}
}
else if (isKindOfClass(obj, CCString))
{
//CCLOG("String recognized");
node.append_child("string").append_child(node_pcdata).set_value(((CCString*)obj)->getCString());
}
else if (isKindOfClass(obj, CCInteger))
{
//CCLOG("Integer recognized");
int value = TOINT(obj);
CCString* stringVal = ScreateF("%d", value);
node.append_child("integer").append_child(node_pcdata).set_value(stringVal->getCString());
}
else if (isKindOfClass(obj, CCFloat))
{
//CCLOG("Float recognized");
float value = TOFLOAT(obj);
CCString* stringVal = ScreateF("%g", value);
node.append_child("real").append_child(node_pcdata).set_value(stringVal->getCString());
}
else if (isKindOfClass(obj, CCBool))
{
//CCLOG("Bool recognized");
bool value = TOBOOL(obj);
node.append_child(value ? "true" : "false");
}
#if VERBOSE_SAVE_PLIST
else
{
CCLOG("Warning: unrecognized type %s when saving plist, check if the object is in plist format", typeid(*obj).name());
}
#endif
}
示例9: useItem
void RequestList::useItem(CCObject* pSender)
{
if (pSender == NULL)
{
return;
}
CCMenuItemImage* sender = (CCMenuItemImage*)pSender;
CCLOG("Call for useItem for tag = %d", sender->getTag());
if (sender->getTag() > _fbIncomingRequestList->count())
{
return;
}
std::string messageToDisplay = "";
EziFBIncomingRequest* fbRequest = (EziFBIncomingRequest*)_fbIncomingRequestList->objectAtIndex(sender->getTag());
if (fbRequest->isConsumed())
{
CCMessageBox("This item is already consumed.", "Consume Item Status");
return;
}
EziSocialWrapperNS::FB_REQUEST::TYPE requestType = fbRequest->getRequestType();
const char* senderName = fbRequest->getSender()->getName();
const char* requestTypeChar = "";
const char* message = "";
message = fbRequest->getMessage();
CCDictionary* giftDictionary = fbRequest->getDataDictionary();
switch (requestType)
{
case EziSocialWrapperNS::FB_REQUEST::REQUEST_INVITE:
requestTypeChar = "Invite";
break;
case EziSocialWrapperNS::FB_REQUEST::REQUEST_GIFT:
requestTypeChar = "Gift";
break;
case EziSocialWrapperNS::FB_REQUEST::REQUEST_CHALLENGE:
requestTypeChar = "Challenge";
break;
default:
requestTypeChar = "Unknown";
break;
}
// Add the request Type
messageToDisplay.append("Request Type = ").append(requestTypeChar).append("\n");
// Add the sender Name
messageToDisplay.append("Sender = ").append(senderName).append("\n");
// Add the message.
messageToDisplay.append("Message = ").append(message).append("\n");
if (giftDictionary && giftDictionary->count()>0)
{
CCArray* allKeys = giftDictionary->allKeys();
if (allKeys && allKeys->count() > 0)
{
messageToDisplay.append("Extra/Gift items sent:\n");
for (int i=0; i<allKeys->count(); i++)
{
CCString* key = (CCString*)allKeys->objectAtIndex(i);
CCString* value = (CCString*)giftDictionary->objectForKey(key->getCString());
messageToDisplay.append(key->getCString()).append(": ").append(value->getCString()).append("\n");
}
}
}
else
{
messageToDisplay.append("No Extra Items were sent by sender");
}
CCMessageBox(messageToDisplay.c_str(), "Item Consumed!!! :)))");
EziFBIncomingRequestManager::sharedManager()->consumeItem(fbRequest);
CCScene *pScene = CCScene::create();
RequestList *pLayer = RequestList::create();
pScene->addChild(pLayer);
CCDirector::sharedDirector()->replaceScene(pScene);
}
示例10: tableCellTouched
void RequestList::tableCellTouched(CCTableView *table, CCTableViewCell *cell)
{
CCLOG("cell touched at index: %i", cell->getIdx());
std::string messageToDisplay = "";
EziFBIncomingRequest* fbRequest = (EziFBIncomingRequest*)_fbIncomingRequestList->objectAtIndex(cell->getIdx());
EziSocialWrapperNS::FB_REQUEST::TYPE requestType = fbRequest->getRequestType();
const char* senderName = fbRequest->getSender()->getName();
const char* requestTypeChar = "";
const char* message = "";
message = fbRequest->getMessage();
CCDictionary* giftDictionary = fbRequest->getDataDictionary();
switch (requestType)
{
case EziSocialWrapperNS::FB_REQUEST::REQUEST_INVITE:
requestTypeChar = "Invite";
break;
case EziSocialWrapperNS::FB_REQUEST::REQUEST_GIFT:
requestTypeChar = "Gift";
break;
case EziSocialWrapperNS::FB_REQUEST::REQUEST_CHALLENGE:
requestTypeChar = "Challenge";
break;
default:
requestTypeChar = "Unknown";
break;
}
// Add the request Type
messageToDisplay.append("Request Type = ").append(requestTypeChar).append("\n");
// Add the sender Name
messageToDisplay.append("Sender = ").append(senderName).append("\n");
// Add the message.
messageToDisplay.append("Message = ").append(message).append("\n");
if (giftDictionary && giftDictionary->count()>0)
{
CCArray* allKeys = giftDictionary->allKeys();
if (allKeys && allKeys->count() > 0)
{
messageToDisplay.append("Extra/Gift items sent:\n");
for (int i=0; i<allKeys->count(); i++)
{
CCString* key = (CCString*)allKeys->objectAtIndex(i);
CCString* value = (CCString*)giftDictionary->objectForKey(key->getCString());
messageToDisplay.append(key->getCString()).append(": ").append(value->getCString()).append("\n");
}
}
}
else
{
messageToDisplay.append("No Extra Items were sent by sender");
}
CCMessageBox(messageToDisplay.c_str(), "Request Details");
}
示例11: intAtArray
void Live2dXSprite::convertDictToConfig(CCDictionary* config)
{
CCDictionary* property = (CCDictionary*)config->objectForKey("property");
m_baseSize.width = property->valueForKey("width")->intValue();
m_baseSize.height = property->valueForKey("height")->intValue();
CCDictionary* unit_list = (CCDictionary*)config->objectForKey("unit_list");
CCArray* unit_names = unit_list->allKeys();
for (int i = 0; i < unit_names->count(); ++i)
{
CCString* unit_name = (CCString*)unit_names->objectAtIndex(i);
CCDictionary* unit = (CCDictionary*)unit_list->objectForKey(unit_name->m_sString);
CCArray* point = (CCArray*)unit->objectForKey("point");
CCArray* triangle = (CCArray*)unit->objectForKey("triangle");
Live2dX_TriangleList& triangle_list = m_all_units[unit_name->m_sString];
for (int k = 0; k < triangle->count(); ++k)
{
CCArray* triangle_one = (CCArray*)triangle->objectAtIndex(k);
int point_index[3];
point_index[0] = intAtArray(0, triangle_one);
point_index[1] = intAtArray(1, triangle_one);
point_index[2] = intAtArray(2, triangle_one);
Live2dX_Triangle tconfig;
for (int m = 0; m < 3; ++m)
{
CCArray* origin_points = (CCArray*)point->objectAtIndex(point_index[m]);
Live2dX_UV uv = {floatAtArray(0,origin_points),floatAtArray(1,origin_points)};
Live2dX_Vertex vertex = {floatAtArray(2,origin_points),floatAtArray(3,origin_points),0};
int point_id = (int)m_orginUV.size();
m_orginUV.push_back(uv);
m_orginVertex.push_back(vertex);
m_nowVertex.push_back(vertex);
m_orginColor.push_back(ccc4(0xff, 0xff,0xff, 0xff));
tconfig.point[m] = point_id;
tconfig.orginPoint[m] = point_index[m];
}
triangle_list.push_back(tconfig);
}
// m_all_units[unit_name->m_sString] = triangle_list;
CCDictionary* animation = (CCDictionary*)unit->objectForKey("animation");
if(animation)
{
map<string,Live2dX_Unit_Anims>& anim2 = m_all_unitanims[unit_name->m_sString];
CCArray* unit_anim_names = animation->allKeys();
for (int k = 0; k < unit_anim_names->count(); ++k)
{
CCString* unit_anim_name = (CCString*)unit_anim_names->objectAtIndex(k);
CCArray* unit_anims = (CCArray*)animation->objectForKey(unit_anim_name->m_sString);
Live2dX_Unit_Anims& unit_anims2 = anim2[unit_anim_name->m_sString];
for (int m = 0; m < unit_anims->count(); ++m)
{
CCDictionary* anim_item = (CCDictionary*)unit_anims->objectAtIndex(m);
Live2dX_Unit_Anim anim;
anim.type = (Live2dX_Animation_Type)anim_item->valueForKey("type")->intValue();
anim.start_perc = anim_item->valueForKey("start")->floatValue();
anim.end_perc = anim_item->valueForKey("end")->floatValue();
CCArray* value = (CCArray*)anim_item->objectForKey("value");
map<int,Live2dX_Unit_Anim_Pos> anim_pos;
int anim_id = m_all_point_move.size();
anim.anim_id = anim_id;
for (int n = 0; n < value->count(); ++n)
{
CCDictionary* value_item = (CCDictionary*)value->objectAtIndex(n);
Live2dX_Unit_Anim_Pos value = {
value_item->valueForKey("x")->floatValue(),
value_item->valueForKey("y")->floatValue(),
value_item->valueForKey("x_move")->floatValue(),
value_item->valueForKey("y_move")->floatValue(),
};
anim_pos[value_item->valueForKey("id")->intValue()] = value;
}
m_all_point_move.push_back(anim_pos);
unit_anims2.push_back(anim);
}
}
}
}
CCDictionary* animation = (CCDictionary*)config->objectForKey("animation");
CCArray* animation_names = animation->allKeys();
for (int i = 0;animation_names != NULL && i < animation_names->count(); ++i)
{
CCString* animation_name = (CCString*)animation_names->objectAtIndex(i);
CCArray* animation_items = (CCArray*)animation->objectForKey(animation_name->m_sString);
Live2dX_Anims& anim_list = m_all_anims[animation_name->m_sString];
for (int k = 0; k < animation_items->count(); ++k)
{
CCDictionary* animation_item = (CCDictionary*)animation_items->objectAtIndex(k);
Live2dX_Anim value = {
&m_all_unitanims[animation_item->valueForKey("unit_name")->m_sString][animation_item->valueForKey("anim_name")->m_sString],
animation_item->valueForKey("unit_name")->m_sString,
animation_item->valueForKey("delay")->floatValue(),
animation_item->valueForKey("time")->floatValue()
};
//.........这里部分代码省略.........
示例12: touchDownAction
void QuestionLayer::touchDownAction(CCObject *sender, CCControlEvent controlEvent)
{
CCLOG("QuestionLayer::touchDownAction");
if (isAnswerFinished) {
return;
}
this->unschedule(schedule_selector(QuestionLayer::timerCB));
CCControlButton* button = (CCControlButton *)sender;
CCLOG("%d", button->getTag());
button->setEnabled(false);
bool bFind = false;
CCDictionary* results = questionObj->rightAnswer;
for (int i=0; i<results->allKeys()->count(); i++) {
CCString* key = (CCString *)(results->allKeys()->objectAtIndex(i));
if (key->intValue() == button->getTag()) {
results->setObject(CCString::createWithFormat("%d", 1), key->getCString());
bFind = true;
break;
}
}
if (bFind) {
//统计已经回答正确答案的数量
int rCount = 0;
for (int i=0; i<results->allKeys()->count(); i++) {
CCString* key = (CCString *)(results->allKeys()->objectAtIndex(i));
CCString* value = (CCString *)(results->objectForKey(key->getCString()));
if (value->intValue() == 1) {
rCount++;
}
}
CCLOG("rCount:%d", rCount);
if (rCount == results->allKeys()->count()) {
//回答完成所有正确答案
for (int i=0; i<results->allKeys()->count(); i++) {
CCString* key = (CCString *)(results->allKeys()->objectAtIndex(i));
CCControlButton* btn = (CCControlButton *)(this->getChildByTag(key->intValue()));
CCSprite* spr = CCSprite::create("star000.png");
spr->setAnchorPoint(ccp(0.5f, 0.5f));
spr->setPosition(ccp(button->getContentSize().width/2, button->getContentSize().height/2));
btn->addChild(spr);
CCBlink* blink = CCBlink::create(1.0f, 3);
if (i < results->allKeys()->count()-1) {
spr->runAction(blink);
} else {
CCAction* pAction = CCCallFuncND::create(this, callfuncND_selector(QuestionLayer::noticeDelegate), NULL);
spr->runAction(CCSequence::create(blink, pAction, NULL));
}
}
rightAnswer++;
if (timerCount >= timerTotal*2/3) {
rightLimit += 1;
//播放快速答题音效
GameSoundManager::shareManager()->playAnswerCool();
} else {
//播放普通答题正确音效
GameSoundManager::shareManager()->playAnswerRight();
}
isAnswerFinished = true;
} else {
CCLOG("正确答案没选完");
}
} else {
//回答错误
CCSprite* spr = CCSprite::create("arrow000.png");
spr->setAnchorPoint(ccp(0.5f, 0.5f));
spr->setPosition(ccp(button->getContentSize().width/2, button->getContentSize().height/2));
button->addChild(spr);
CCFadeIn* fadeIn = CCFadeIn::create(1.0f);
CCAction* pAction = CCCallFuncND::create(this, callfuncND_selector(QuestionLayer::noticeDelegate), NULL);
spr->runAction(CCSequence::create(fadeIn, pAction, NULL));
errorAnswer++;
isAnswerFinished = true;
//播放错误音效
GameSoundManager::shareManager()->playAnswerError();
}
}
示例13: getConfigOfMapLevel
MapItem* CData::getConfigOfMapLevel(int levelid)
{
if(m_config_map_level_dic->count()<1)
{
Json::Reader read;
Json::Value root;
Json::Value data;
Json::Value list;
string path = CCFileUtils::sharedFileUtils()->fullPathForFilename("map.json");
CCString* str = CCString::createWithContentsOfFile(path.c_str());
int sz = 0;
if(read.parse(str->getCString(), root)){
data = root["data"];
sz = data.size();
for (int i = 0; i < sz; i++) {
MapItem *item = new MapItem();
// item->autorelease();
item->nickname = data[i]["name"].asString();
item->desc = data[i]["desc"].asString();
item->bid = data[i]["id"].asInt();
item->exp = data[i]["exp"].asInt();
item->coin = data[i]["coin"].asInt();
// item->itemId = root[i]["dropicon"].asInt();
list = data[i]["mconfig"];
CCDictionary* dic = CCDictionary::create();
int len =list.size();
for (int ei = 0; ei < len; ei++)
{
int iiiiid = list[ei].asInt();
configMonsterItem* hitem =CData::getCData()->getConfigOfMonster(iiiiid);
if(hitem != NULL)
{
dic->setObject(hitem, hitem->nickname);
}
else{
char iii[100] = "";
sprintf(iii, "怪物id不存在 %d",iiiiid);
CCLog(iii);
}
}
char chars[500] = "";
int how = dic->count();
CCArray* arr = dic->allKeys();
switch (how) {
case 1:
sprintf(chars, "【%s】",((CCString*)(arr->objectAtIndex(0)))->getCString());
break;
case 2:
sprintf(chars, "【%s】\n【%s】",((CCString*)(arr->objectAtIndex(0)))->getCString(),((CCString*)(arr->objectAtIndex(1)))->getCString());
break;
case 3:
sprintf(chars, "【%s】 【%s】\n【%s】",((CCString*)(arr->objectAtIndex(0)))->getCString(),((CCString*)(arr->objectAtIndex(1)))->getCString(),((CCString*)(arr->objectAtIndex(2)))->getCString());
break;
default:
if(how >= 4)
{
sprintf(chars, "【%s】 【%s】\n【%s】 【%s】",((CCString*)(arr->objectAtIndex(0)))->getCString(),
((CCString*)(arr->objectAtIndex(1)))->getCString(),
((CCString*)(arr->objectAtIndex(2)))->getCString(),((CCString*)(arr->objectAtIndex(3)))->getCString());
}
break;
}
item->enemydesc = chars;
CCLog(item->enemydesc.c_str());
m_config_map_level_dic->setObject(item, item->bid);
}
}
}
return (MapItem*)m_config_map_level_dic->objectForKey(levelid);
}