本文整理汇总了C++中CCDictionary::valueForKey方法的典型用法代码示例。如果您正苦于以下问题:C++ CCDictionary::valueForKey方法的具体用法?C++ CCDictionary::valueForKey怎么用?C++ CCDictionary::valueForKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCDictionary
的用法示例。
在下文中一共展示了CCDictionary::valueForKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createTargets
void GameScene::createTargets(int iLevel)
{
// if(iLevel >= m_pEnemyInfos->count())
// {
// iLevel = 0;
// global::setGameLevel(iLevel);
//
// m_popView = new PopUpView("popUpBGg.png", "Yeah", "你已经通关,真厉害~", "OK",menu_selector(GameScene::backToMainMenu), "Cancel",menu_selector(GameScene::backToMainMenu),this);
// this->addChild(m_popView,20);
// return;
// }
CCDictionary * pEnemyNumDic = (CCDictionary*)((CCArray*)m_pEnemyInfos->objectAtIndex(iLevel))->objectAtIndex(0);
m_iCurrentEnemy = pEnemyNumDic->valueForKey("EnemyNumber")->intValue();
CCArray * pEnemys = (CCArray*)((CCArray*)m_pEnemyInfos->objectAtIndex(iLevel))->objectAtIndex(1);
for(int i = 0;i < pEnemys->count();i++)
{
CCDictionary * pEnemyDic = (CCDictionary*)pEnemys->objectAtIndex(i);
CCString * imageName = (CCString*)pEnemyDic->objectForKey("imageName");
float positionX = pEnemyDic->valueForKey("positionX")->floatValue();
float positionY = pEnemyDic->valueForKey("positionY")->floatValue();
float rotation = pEnemyDic->valueForKey("rotation")->floatValue();
bool isCircle = pEnemyDic->valueForKey("isCircle")->boolValue();
bool isStatic = pEnemyDic->valueForKey("isStatic")->boolValue();
bool isEnemy = pEnemyDic->valueForKey("isEnemy")->boolValue();
// CCLog("imageName->%s",imageName->getCString());
// CCLog("positionX->%f,positionY->%f",positionX,positionY);
createTarget((char*)imageName->getCString(), CCPointMake(positionX, positionY), rotation, isCircle, isStatic, isEnemy);
}
}
示例2: loadLevel
void GameLayer::loadLevel (int level) {
clearLayer();
_currentLevel = level;
resetLevel();
CCDictionary * levelData = (CCDictionary *) _levels->objectAtIndex(_currentLevel);
int count;
CCDictionary * data;
//create platforms
CCArray * platforms = (CCArray *) levelData->objectForKey("platforms");
Platform * platform;
count = platforms->count();
for (int i = 0; i < count; i++) {
platform = (Platform *) _platformPool->objectAtIndex(_platformPoolIndex);
_platformPoolIndex++;
if (_platformPoolIndex == _platformPool->count()) _platformPoolIndex = 0;
data = (CCDictionary *) platforms->objectAtIndex(i);
platform->initPlatform (
data->valueForKey("width")->intValue() * TILE,
data->valueForKey("angle")->floatValue(),
ccp(data->valueForKey("x")->floatValue() * TILE,
data->valueForKey("y")->floatValue() * TILE)
);
}
}
示例3: Init
void LevelMgr::Init(CCLayer* layer)
{
mGameLayer = layer;
//¶ÁfishInfo
const char* testPlistPath = "fish/GamePart.plist";
std::string str1 = CCFileUtils::sharedFileUtils()->fullPathForFilename(testPlistPath);
CCDictionary* plistDic = CCDictionary::createWithContentsOfFile(str1.c_str());
mLevelCount = plistDic->count();
char str[64] = {0};
for(int i=1;i<=mLevelCount;i++)
{
sprintf(str,"level%d",i);
CCDictionary* levelDic = dynamic_cast<CCDictionary*>(plistDic->objectForKey(str));
LevelInfo levelInfo;
strcpy(levelInfo.fishList,levelDic->valueForKey("fish")->getCString());
strcpy(levelInfo.fishCount,levelDic->valueForKey("fishCount")->getCString());
levelInfo.time = levelDic->valueForKey("time")->intValue();
strcpy(levelInfo.music,levelDic->valueForKey("bgMusic")->getCString());
CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic(levelInfo.music);
strcpy(levelInfo.background,levelDic->valueForKey("background")->getCString());
mLevelInfoList.push_back(levelInfo);
}
mMainFrame = UIMgr::Instance()->GetMainFrame();
// Ô¤¼ÓÔØÒôÀÖºÍÒôЧ
}
示例4: handleRecieve
bool PaymentTstoreCommand::handleRecieve(cocos2d::CCDictionary *dict)
{
if (dict->valueForKey("cmd")->compare(PAYMENT_TSTORE_COMMAND) != 0)
return false;
PayController::getInstance()->setGoldExchangeSaleBoughtFlag(m_itemId, false);
CCDictionary *params = _dict(dict->objectForKey("params"));
if (m_orderId.compare(params->valueForKey("orderId")->getCString()) != 0) {
return false;
}
if (params->objectForKey("errorCode")) {
callFail(NetResult::createWithFail(params));
return true;
}
int status = params->valueForKey("status")->intValue();
if(CCCommonUtils::payParseData(params))
{
auto ret = CCDictionary::create();
ret->setObject(CCInteger::create(status), "status");
ret->setObject(CCString::create(m_orderId), "orderId");
callSuccess(NetResult::createWithSuccess(ret));
}
return true;
}
示例5: handleRecieve
bool LotteryBuyCmd::handleRecieve(CCDictionary* dict)
{
if (dict->valueForKey("cmd")->compare(LOTTERY_BUY_COMMAND) != 0) {
return false;
}
CCDictionary* params = _dict(dict->objectForKey("params"));
const CCString *pStr = params->valueForKey("errorCode");
if (pStr->compare("")!=0)
{
CCCommonUtils::flyText((_lang(pStr->getCString()).c_str()));
// return true;
}
if (params->objectForKey("chip"))
{
GlobalData::shared()->resourceInfo.lChip = params->valueForKey("chip")->intValue();
}
if (params->objectForKey("gold"))
{
GlobalData::shared()->playerInfo.gold = params->valueForKey("gold")->intValue();
CCSafeNotificationCenter::sharedNotificationCenter()->postNotification(MSG_CITY_RESOURCES_UPDATE);
}
CCSafeNotificationCenter::sharedNotificationCenter()->postNotification("BUYCHIPBACK", params);
return true;
}
示例6: prepareHillKeyPoint
void Terrain::prepareHillKeyPoint(MyMap* myMap)
{
CCPoint offsetPosition = myMap->_map->getPosition();
CCTMXObjectGroup* objGroup = myMap->_map->objectGroupNamed("platform");
CCDictionary* dict = objGroup->objectNamed("platform");
/*对象位置**/
int x = ((CCString*)dict->objectForKey("x"))->intValue();
int y = ((CCString*)dict->objectForKey("y"))->intValue();
/*刚体关键点**/
CCArray* points = (CCArray*)dict->objectForKey("points");
CCObject* pObj = NULL;
CCDictionary* point = NULL;
CCARRAY_FOREACH(points, pObj) {
point = (CCDictionary*)pObj;
_hillKeyPoints[_hillKeyPointIndex++] = ccp(
offsetPosition.x + x + ((CCString*)point->valueForKey("x"))->intValue(),
offsetPosition.y + y - ((CCString*)point->valueForKey("y"))->intValue()
);
if (_hillKeyPointIndex >= kMaxPlatformKeyPoints)
{
_hillKeyPointIndex = 0;
}
_lastHillKeyPoint = ccp(
x + ((CCString*)point->valueForKey("x"))->intValue(),
y - ((CCString*)point->valueForKey("y"))->intValue()
);
}
示例7: handleRecieve
bool AlPointFindCommand::handleRecieve(CCDictionary* dict)
{
if (dict->valueForKey("cmd")->compare(AL_POINT_FIND) != 0)
return false;
CCDictionary* params = _dict(dict->objectForKey("params"));
if (params->objectForKey("errorCode")) {
CCCommonUtils::flyText(_lang(params->valueForKey("errorCode")->getCString()));
} else {
if (params->objectForKey("targetPoint")) {
int point = params->valueForKey("targetPoint")->intValue();
if (point <= 0) {
if (m_op == 0)
{
if (point == 0)
{
CCCommonUtils::flyText(_lang("115427"));
}
} else if (m_op == 1) {
if (point == 0)
{
CCCommonUtils::flyText(_lang("115426"));
} else if (point == -1) {
CCCommonUtils::flyText(_lang("115425"));
}
}
} else {
//zym 2015.12.10
//PopupViewController::getInstance()->removeAllPopupView();
PopupViewController::getInstance()->forceClearAll();
auto& info = ToolController::getInstance()->getToolInfoById(ITEM_ALLIANCE_CITY_MOVE);
if (info.getCNT() <= 0) {
return true;
}
if (m_op == 0)
{
AllianceManager::getInstance()->goToWorldType = 2;
} else if (m_op == 1) {
AllianceManager::getInstance()->goToWorldType = 3;
}
CCPoint pt = WorldController::getPointByIndex(point);
WorldController::getInstance()->openTargetIndex = point;
std::string isFirstPopKey = GlobalData::shared()->playerInfo.uid + "isFirstPop";
int isFirstPop = CCUserDefault::sharedUserDefault()->getIntegerForKey(isFirstPopKey.c_str(),0);
if(SceneController::getInstance()->currentSceneId == SCENE_ID_WORLD) {
WorldMapView::instance()->gotoTilePoint(pt, GlobalData::shared()->playerInfo.selfServerId);
} else {
if (isFirstPop==0) {
WorldController::getInstance()->firstInWorld = true;
isFirstPop = 1;
CCUserDefault::sharedUserDefault()->setIntegerForKey(isFirstPopKey.c_str(), isFirstPop);
CCUserDefault::sharedUserDefault()->flush();
}
SceneController::getInstance()->gotoScene(SCENE_ID_WORLD, false, true, point);
}
}
}
}
return true;
}
示例8: load
//private
void HMusicManager::load() {
//delete by zg
CCDictionary *dict = NULL; //HFileUtils::loadFromLocal("settings");
if (dict) {
m_fBGMusicVolume = dict->valueForKey("musicVolume")->floatValue();
m_fSoundEffectVolume = dict->valueForKey("effectsVolume")->floatValue();
}
}
示例9: dispatchPacket
// TODO: @student : extend the protocol.
// so the receiver can split the package into name and content
void ClientChatNetPackageDispatcher::dispatchPacket(unsigned char packetIdentifier, NativePacket* nativePacket )
{
NetMessageIDTypes eNetMessageID(static_cast<NetMessageIDTypes>(packetIdentifier));
const bool validMessageId((eNetMessageID > NETMSG_ID_START) && (eNetMessageID < NETMSG_ID_END));
if(validMessageId == false) {
return;
}
switch(eNetMessageID) {
case NETMSG_ID_CHATLINE:
{
const char* message = (const char*)nativePacket->data;
// skip the packet identifier
message++;
if(isEmptyString(message) == true) {
getPeer()->log(ELogType_Error, "received an empty chat message");
}
else {
// TODO: @student : split the packet ...
ChatMessage chatMessage("---", message);
addChatMessage(chatMessage);
}
}
break;
case NETMSG_ID_JSONOBJECT:
{
// TODO: @student : this might not be enough ...
const char* message = (const char*)nativePacket->data;
// skip the packet identifier
message++;
if(isEmptyString(message) == true) {
getPeer()->log(ELogType_Error, "received an empty chat message");
}
else {
SLAString json(message);
getPeer()->log(ELogType_Info, "received json %s", json.c_str());
CCDictionary* dictionary = CCJSONConverter::dictionaryFrom(json.c_str());
getPeer()->log(ELogType_Info, dictionary);
// DONE: @student : read the relevant dictionary members and pass them to the chat message
CCObject *aMessage = dictionary->objectForKey("message");
CCDictionary *messDictionary = dynamic_cast<CCDictionary*>(aMessage);
const CCString *aSender = messDictionary->valueForKey("sender");
const CCString *aContent = messDictionary->valueForKey("content");
ChatMessage chatMessage(aSender->getCString(), aContent->getCString());
addChatMessage(chatMessage);
}
}
break;
default:
break;
}
}
示例10: setPlayerPosition
void HelloWorld::setPlayerPosition(CCPoint position)
{
SimpleAudioEngine::sharedEngine()->playEffect("move.wav");
CCPoint tileCoord = this->tileCoordForPosition(position);
int tileGid = mapLayer->tileGIDAt(tileCoord);
if (tileGid)
{
CCDictionary *properties = map->propertiesForGID(tileGid);
CCLog("%d\n",tileGid);
if (properties)
{
const CCString *collision = properties->valueForKey("Collidable");
CCLog("%s\n",collision->getCString());
if (collision && collision->compare("true") ==0)
{
SimpleAudioEngine::sharedEngine()->playEffect("hit.wav");
return;
}
}
const CCString *collectable = properties->valueForKey("Collectable");
if (collectable && collectable->compare("true") ==0)
{
count+=1;
SimpleAudioEngine::sharedEngine()->playEffect("pickup.wav");
CountLayer *countLayer =(CountLayer *) this->getParent()->getChildByTag(1);
if(countLayer!=NULL)
{
countLayer->countChange(count);
}
else
{
CCLog("*************error\n");
}
mapLayer->removeTileAt(tileCoord);
foreground->removeTileAt(tileCoord);
}
}
player->setPosition(position);
//player->setPosition(position);
}
示例11: addRewardsNodeByIndex
void LotteryRotateView::addRewardsNodeByIndex(int idx){
nodeParticleIdx = idx;
string iconStr = "";
CCDictionary* dict = dynamic_cast<CCDictionary*>(m_save10Arr->objectAtIndex(idx));
int dictType = dict->valueForKey("type")->intValue();
CCDictionary* rewardsDic = _dict(dict->objectForKey("result"));
if (dictType == 0) {//RESOURCE
int resType = rewardsDic->valueForKey("type")->intValue();
iconStr = LotteryController::shared()->getIcon(resType);
}else if (dictType == 1){//BOX_TIMES
iconStr = LotteryController::shared()->getIcon(100);
}else if (dictType == 2){//REWARD
int resType = rewardsDic->valueForKey("type")->intValue();
if (resType == 7) {
CCDictionary* valueDic = _dict(rewardsDic->objectForKey("value"));
int itemId = valueDic->valueForKey("itemId")->intValue();
iconStr = CCCommonUtils::getIcon(CC_ITOA(itemId));
}else{
iconStr = LotteryController::shared()->getIcon(resType);
}
}
auto rewardIcon =CCLoadSprite::createSprite(iconStr.c_str());
CCCommonUtils::setSpriteMaxSize(rewardIcon, 80);
if (nodeParticleIdx<5) {
rewardIcon->setPosition((100*nodeParticleIdx)-200, 45);
}else{
rewardIcon->setPosition((100*(nodeParticleIdx-5))-200, -45);
}
rewardIcon->setOpacity(0.5);
CCActionInterval *fadeIn = CCFadeIn::create(0.3);
rewardIcon->setScale(0.8);
CCActionInterval *scale1 = CCScaleTo::create(0.1, 1.2);
CCActionInterval *scale2 = CCScaleTo::create(0.1, 1.0);
//粒子特效
CCNode *pNode = CCNode::create();
pNode->setPosition(rewardIcon->getPosition());
m_rewardsContainer->addChild(pNode);
auto func =CCCallFuncO::create(this, callfuncO_selector(LotteryRotateView::addRewardsNodeParticle),pNode);
rewardIcon->runAction(CCSequence::create(fadeIn,scale1,scale2,func, NULL));
m_rewardsContainer->addChild(rewardIcon);
// string m_itemId="200380";
// int id = atoi(m_itemId.c_str());
// CCCommonUtils::flyHintWithDefault("Lottery_wood.png", "", _lang_1("104913", LotteryController::shared()->getLotteryName(id, 100).c_str()),0.5);
//飘字特效
// ccColor3B textColor = TEXT_COLOR_YELLOW;
// CCCommonUtils::flyUiResText("Lottery_wood.png", m_rewardsContainer,ccp(0, 0) ,textColor, floating_type_ui1, 23);
}
示例12: parseAction
CCAction* ParserBezierTo::parseAction(cocos2d::CCDictionary *dict)
{
float duration = dict->valueForKey("Duration")->floatValue();
ccBezierConfig config;
CCDictionary* configDict = (CCDictionary*)dict->objectForKey("BezierConfig");
config.endPosition = CCPointFromString(configDict->valueForKey("EndPosition")->getCString());
config.endPosition = pointWithContentScale(config.endPosition);
config.controlPoint_1 = CCPointFromString(configDict->valueForKey("ControlPoint1")->getCString());
config.controlPoint_1 = pointWithContentScale(config.controlPoint_1);
config.controlPoint_2 = CCPointFromString(configDict->valueForKey("ControlPoint2")->getCString());
config.controlPoint_2 = pointWithContentScale(config.controlPoint_2);
return CCBezierTo::create(duration, config);
}
示例13: onGetFriendInfoSuccess
void GetFriendListCommand::onGetFriendInfoSuccess(CCObject* pObj)
{
CCLOGFUNC("");
CCDictionary* params = dynamic_cast<CCDictionary*>(pObj);
if (params==NULL || ChatController::getInstance()->m_chatUserInfoDic==NULL) {
return;
}
CCArray* members = dynamic_cast<CCArray*>(params->objectForKey("contactList"));
string uidStr="";
string lastUpdateTimeStr="";
if(members)
{
vector<std::string> *uids = new vector<std::string>();
CCLOGFUNCF("members->count():%d",members->count());
for (int i=0; i < members->count(); i++) {
CCDictionary* member = (CCDictionary*)members->objectAtIndex(i);
string uid=member->valueForKey("uid")->getCString();
if(uid!="")
{
if (ChatController::getInstance()->m_chatUserInfoDic->objectForKey(uid)==NULL) {
uids->push_back(uid);
}
string time=member->valueForKey("lastUpdateTime")->getCString();
if (time=="") {
time="0";
}
if(uidStr!="")
{
uidStr.append("_").append(uid);
lastUpdateTimeStr.append("_").append(time);
}
else
{
uidStr=uid;
lastUpdateTimeStr=time;
}
}
}
CCLOGFUNCF("uidStr:%s",uidStr.c_str());
}
#if(CC_TARGET_PLATFORM==CC_PLATFORM_ANDROID)
if (uidStr!="") {
ChatServiceCocos2dx::notifyUserUids(uidStr,lastUpdateTimeStr,GET_MUTIUSER_TYPE_FRIEND);
}
#endif
}
示例14: setPlayerPosition
// do not move to Player.h
void Game::setPlayerPosition(CCPoint position, CCFiniteTimeAction* sequence)
{
CCPoint tileCoord = this->tileCoordForPosition(position);
int tileGid = _meta->tileGIDAt(tileCoord);
if (tileGid) {
CCDictionary *properties = _tileMap->propertiesForGID(tileGid);
if (properties) {
// obstacle
CCString *collision = new CCString();
*collision = *properties->valueForKey("Collidable");
// Moveable
CCString *move = new CCString();
*move = *properties->valueForKey("Moveable");
// Breakable
CCString *breakable = new CCString();
*breakable = *properties->valueForKey("Breakable");
if ((collision && collision->compare("True") == 0) ||
(move && move->compare("True") == 0) ||
(breakable && breakable->compare("True") == 0)) {
// 動けない音を出す
CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("hit.caf");
this->finishAnimation();
CCLog("Can't move");
return;
}
// item get
CCString *collectable = new CCString();
*collectable = *properties->valueForKey("Collectable");
if (collectable && (collectable->compare("True") == 0)) {
// 取り除く
_meta->removeTileAt(tileCoord);
_foreground->removeTileAt(tileCoord);
_numCollected++;
_hud->numCollectedChanged(_numCollected);
CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("pickup.caf");
}
}
}
_player->runAction(sequence);
// not hit only 赤にする
this->setTileEffect(position);
CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("move.caf");
}
示例15: init
bool HelpScene::init()
{
if (!Layer::init())
{
return false;
}
auto size = Director::getInstance()->getWinSize();
auto visible = Director::getInstance()->getVisibleSize();
auto origin = Director::getInstance()->getVisibleOrigin();
//ÉèÖñ³¾°
auto spriteBK = Sprite::create("background.png");
spriteBK->setPosition(size.width / 2, size.height / 2);
spriteBK->setOpacity(75);
this->addChild(spriteBK, 0);
//¶ÁÈ¡xml×Ö·û
CCDictionary* message = CCDictionary::createWithContentsOfFile("chinese.xml");
auto helpTitleKey = message->valueForKey("helpTitle");
const char* helpTitle = helpTitleKey->getCString();
//°ïÖúÐÅÏ¢
auto helpTitleLabel = Label::createWithTTF(helpTitle, "fonts/newSongTi.ttf", 25);
helpTitleLabel->setPosition(Point(
size.width - helpTitleLabel->getContentSize().width,
size.height - helpTitleLabel->getContentSize().height));
this->addChild(helpTitleLabel, 1);
auto helpMessageKey = message->valueForKey("helpMessage");
const char* helpMessage = helpMessageKey->getCString();
auto helpMessageLabel = Label::createWithTTF(helpMessage, "fonts/newSongTi.ttf",20);
helpMessageLabel->setDimensions(300,200);
helpMessageLabel->enableOutline(Color4B(255, 0, 0, 0), 1);
//helpMessageLabel->setAnchorPoint(Point(1,1));
/*helpMessageLabel->setPosition(Point(
size.width - helpTitleLabel->getContentSize().width,
size.height - (helpTitleLabel->getContentSize().height*2)));*/
helpMessageLabel->setPosition(size.width / 2, size.height / 2);
this->addChild(helpMessageLabel, 1);
//·µ»Ø°´Å¥
auto menuItemBack = MenuItemFont::create("Back", CC_CALLBACK_1(HelpScene::gotoMenuCallback, this));
auto menu = Menu::create(menuItemBack, NULL);
menu->setPosition(Point::ZERO);
menuItemBack->setPosition(Point(
size.width - menuItemBack->getContentSize().width,
menuItemBack->getContentSize().height));
this->addChild(menu, 2);
return true;
}