本文整理汇总了C++中DictElement类的典型用法代码示例。如果您正苦于以下问题:C++ DictElement类的具体用法?C++ DictElement怎么用?C++ DictElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DictElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addChild
void BatchNode::addChild(Node *child, int zOrder, int tag)
{
Node::addChild(child, zOrder, tag);
Armature *armature = dynamic_cast<Armature *>(child);
if (armature != nullptr)
{
armature->setBatchNode(this);
const Dictionary *dict = armature->getBoneDic();
DictElement *element = nullptr;
CCDICT_FOREACH(dict, element)
{
Bone *bone = static_cast<Bone*>(element->getObject());
Array *displayList = bone->getDisplayManager()->getDecorativeDisplayList();
for(auto object : *displayList)
{
DecorativeDisplay *display = static_cast<DecorativeDisplay*>(object);
if (Skin *skin = dynamic_cast<Skin*>(display->getDisplay()))
{
skin->setTextureAtlas(getTexureAtlasWithTexture(skin->getTexture()));
}
}
}
示例2: log
void SIOClientImpl::handshakeResponse(HttpClient *sender, HttpResponse *response)
{
log("SIOClientImpl::handshakeResponse() called");
if (0 != strlen(response->getHttpRequest()->getTag()))
{
log("%s completed", response->getHttpRequest()->getTag());
}
int statusCode = response->getResponseCode();
char statusString[64] = {};
sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag());
log("response code: %d", statusCode);
if (!response->isSucceed())
{
log("SIOClientImpl::handshake() failed");
log("error buffer: %s", response->getErrorBuffer());
DictElement* el = NULL;
CCDICT_FOREACH(_clients, el) {
SIOClient* c = static_cast<SIOClient*>(el->getObject());
c->getDelegate()->onError(c, response->getErrorBuffer());
}
示例3: setIndentLevel
void PrettyPrinter::visit(const __Dictionary *p)
{
_result += "\n";
_result += _indentStr;
_result += "<dict>\n";
setIndentLevel(_indentLevel+1);
DictElement* element;
bool bFirstElement = true;
char buf[1000] = {0};
CCDICT_FOREACH(p, element)
{
if (!bFirstElement) {
_result += "\n";
}
sprintf(buf, "%s%s: ", _indentStr.c_str(),element->getStrKey());
_result += buf;
PrettyPrinter v(_indentLevel);
//FIXME:james element->getObject()->acceptVisitor(v);
_result += v.getResult();
bFirstElement = false;
}
setIndentLevel(_indentLevel-1);
_result += "\n";
_result += _indentStr;
_result += "</dict>";
}
示例4: Dictionary
Dictionary* TextureCache::snapshotTextures()
{
Dictionary* pRet = new Dictionary();
DictElement* pElement = NULL;
CCDICT_FOREACH(_textures, pElement)
{
pRet->setObject(pElement->getObject(), pElement->getStrKey());
}
示例5: convertDictionaryToJson
void CCJSONConverter::convertDictionaryToJson(__Dictionary *Dictionary, cJSON *json)
{
#if COCOS2D_VERSION >= 0x00030000
DictElement * pElement = NULL;
#else
CCDictElement * pElement = NULL;
#endif
CCDICT_FOREACH(Dictionary, pElement){
Ref * obj = pElement->getObject();
cJSON * jsonItem = getObjJson(obj);
cJSON_AddItemToObject(json, pElement->getStrKey(), jsonItem);
}
示例6: CCLOG
void AnimationCache::parseVersion1(Dictionary* animations)
{
SpriteFrameCache *frameCache = SpriteFrameCache::sharedSpriteFrameCache();
DictElement* pElement = NULL;
CCDICT_FOREACH(animations, pElement)
{
Dictionary* animationDict = (Dictionary*)pElement->getObject();
Array* frameNames = (Array*)animationDict->objectForKey("frames");
float delay = animationDict->valueForKey("delay")->floatValue();
Animation* animation = NULL;
if ( frameNames == NULL )
{
CCLOG("cocos2d: AnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.", pElement->getStrKey());
continue;
}
Array* frames = Array::createWithCapacity(frameNames->count());
frames->retain();
Object* pObj = NULL;
CCARRAY_FOREACH(frameNames, pObj)
{
const char* frameName = ((String*)pObj)->getCString();
SpriteFrame* spriteFrame = frameCache->spriteFrameByName(frameName);
if ( ! spriteFrame ) {
CCLOG("cocos2d: AnimationCache: Animation '%s' refers to frame '%s' which is not currently in the SpriteFrameCache. This frame will not be added to the animation.", pElement->getStrKey(), frameName);
continue;
}
AnimationFrame* animFrame = new AnimationFrame();
animFrame->initWithSpriteFrame(spriteFrame, 1, NULL);
frames->addObject(animFrame);
animFrame->release();
}
if ( frames->count() == 0 ) {
CCLOG("cocos2d: AnimationCache: None of the frames for animation '%s' were found in the SpriteFrameCache. Animation is not being added to the Animation Cache.", pElement->getStrKey());
continue;
} else if ( frames->count() != frameNames->count() ) {
CCLOG("cocos2d: AnimationCache: An animation in your dictionary refers to a frame which is not in the SpriteFrameCache. Some or all of the frames for the animation '%s' may be missing.", pElement->getStrKey());
}
animation = Animation::create(frames, delay, 1);
AnimationCache::sharedAnimationCache()->addAnimation(animation, pElement->getStrKey());
frames->release();
}
示例7: CCASSERT
//
// load file
//
void Configuration::loadConfigFile(const char *filename)
{
Dictionary *dict = Dictionary::createWithContentsOfFile(filename);
CCASSERT(dict, "cannot create dictionary");
// search for metadata
bool validMetadata = false;
Object *metadata = dict->objectForKey("metadata");
if (metadata && dynamic_cast<Dictionary*>(metadata))
{
Object *format_o = static_cast<Dictionary*>(metadata)->objectForKey("format");
// XXX: cocos2d-x returns Strings when importing from .plist. This bug will be addressed in cocos2d-x v3.x
if (format_o && dynamic_cast<String*>(format_o))
{
int format = static_cast<String*>(format_o)->intValue();
// Support format: 1
if (format == 1)
{
validMetadata = true;
}
}
}
if (! validMetadata)
{
CCLOG("Invalid config format for file: %s", filename);
return;
}
Object *data = dict->objectForKey("data");
if (!data || !dynamic_cast<Dictionary*>(data))
{
CCLOG("Expected 'data' dict, but not found. Config file: %s", filename);
return;
}
// Add all keys in the existing dictionary
Dictionary *data_dict = static_cast<Dictionary*>(data);
DictElement* element;
CCDICT_FOREACH(data_dict, element)
{
if(! _valueDict->objectForKey( element->getStrKey() ))
_valueDict->setObject(element->getObject(), element->getStrKey());
else
CCLOG("Key already present. Ignoring '%s'", element->getStrKey());
}
}
示例8: setPreferredSize
void ControlButton::setPreferredSize(Size size)
{
if(size.width == 0 && size.height == 0)
{
_doesAdjustBackgroundImage = true;
}
else
{
_doesAdjustBackgroundImage = false;
DictElement * item = NULL;
CCDICT_FOREACH(_backgroundSpriteDispatchTable, item)
{
Scale9Sprite* sprite = static_cast<Scale9Sprite*>(item->getObject());
sprite->setPreferredSize(size);
}
}
示例9: PreSolve
void OneSidedPlatform::PreSolve(b2Contact* contact, const b2Manifold* oldManifold)
{
Test::PreSolve(contact, oldManifold);
b2Fixture* fixtureA = contact->GetFixtureA();
b2Fixture* fixtureB = contact->GetFixtureB();
DictElement * ele;
__Dictionary * itemList = BattleController::shared()->getItemList();
CCDICT_FOREACH(itemList, ele){
Item * item = dynamic_cast<Item*>(ele->getObject());
b2Fixture * itemBox2d = item->getB2fixture();
if (fixtureA == itemBox2d || fixtureB == itemBox2d) {
contact->SetEnabled(false);
break;
}
}
示例10: foreach
//遍历
void CommonDictionary::foreach()
{
DictElement * pElement;
CCDICT_FOREACH(pDict, pElement)
{
const char * key = pElement->getStrKey();
const char* value = (const char*)pDict->objectForKey(key);
printf("CommonDictionary ---> key = %s, value = %s\n", key, value);
//CCLog(key);
//CCLog(value);
//myStrcat(Str, value);
//CCLog(Str);
}
}
示例11: CC_SAFE_RETAIN
Node* CCBReader::readNodeGraphFromData(Data *pData, Object *pOwner, const Size &parentSize)
{
mData = pData;
CC_SAFE_RETAIN(mData);
mBytes = mData->getBytes();
mCurrentByte = 0;
mCurrentBit = 0;
mOwner = pOwner;
CC_SAFE_RETAIN(mOwner);
mActionManager->setRootContainerSize(parentSize);
mActionManager->mOwner = mOwner;
mOwnerOutletNodes = new Array();
mOwnerCallbackNodes = new Array();
Dictionary* animationManagers = Dictionary::create();
Node *pNodeGraph = readFileWithCleanUp(true, animationManagers);
if (pNodeGraph && mActionManager->getAutoPlaySequenceId() != -1 && !jsControlled)
{
// Auto play animations
mActionManager->runAnimationsForSequenceIdTweenDuration(mActionManager->getAutoPlaySequenceId(), 0);
}
// Assign actionManagers to userObject
if(jsControlled) {
mNodesWithAnimationManagers = new Array();
mAnimationManagersForNodes = new Array();
}
DictElement* pElement = NULL;
CCDICT_FOREACH(animationManagers, pElement)
{
Node* pNode = (Node*)pElement->getIntKey();
CCBAnimationManager* manager = static_cast<CCBAnimationManager*>(animationManagers->objectForKey((intptr_t)pNode));
pNode->setUserObject(manager);
if (jsControlled)
{
mNodesWithAnimationManagers->addObject(pNode);
mAnimationManagersForNodes->addObject(manager);
}
}
示例12: setAnimationScale
void ArmatureAnimation::setAnimationScale(float animationScale )
{
if(animationScale == _animationScale)
{
return;
}
_animationScale = animationScale;
DictElement *element = NULL;
Dictionary *dict = _armature->getBoneDic();
CCDICT_FOREACH(dict, element)
{
Bone *bone = (Bone *)element->getObject();
bone->getTween()->setAnimationScale(_animationScale);
if (bone->getChildArmature())
{
bone->getChildArmature()->getAnimation()->setAnimationScale(_animationScale);
}
}
示例13: dictionaryToMap
static void dictionaryToMap(__Dictionary* dict, map<string,string>& ret)
{
if (dict == nullptr)
return;
DictElement* el = nullptr;
CCDICT_FOREACH(dict, el)
{
auto str = dynamic_cast<__String*>(el->getObject());
auto boolean = dynamic_cast<__Bool*>(el->getObject());
auto number = dynamic_cast<__Double*>(el->getObject());
stringstream ss;
if (str)
ss << str->getCString();
else if (boolean)
ss << (int)boolean->getValue();
else if (number)
ss << number->getValue();
ret[el->getStrKey()] = ss.str();
}
示例14: setSpeedScale
void ArmatureAnimation::setSpeedScale(float speedScale)
{
if(speedScale == _speedScale)
{
return;
}
_speedScale = speedScale;
_processScale = !_movementData ? _speedScale : _speedScale * _movementData->scale;
DictElement *element = NULL;
Dictionary *dict = _armature->getBoneDic();
CCDICT_FOREACH(dict, element)
{
Bone *bone = static_cast<Bone*>(element->getObject());
bone->getTween()->setProcessScale(_processScale);
if (bone->getChildArmature())
{
bone->getChildArmature()->getAnimation()->setProcessScale(_processScale);
}
}
示例15: dictionary_to_rubyval
mrb_value dictionary_to_rubyval(mrb_state* mrb, __Dictionary* dict)
{
mrb_value rhash = mrb_hash_new(mrb);
DictElement* element = nullptr;
std::string className = "";
__String* strVal = nullptr;
__Dictionary* dictVal = nullptr;
__Array* arrVal = nullptr;
__Double* doubleVal = nullptr;
__Bool* boolVal = nullptr;
__Float* floatVal = nullptr;
__Integer* intVal = nullptr;
CCDICT_FOREACH(dict, element) {
if (nullptr == element)
continue;
mrb_value rkey = mrb_str_new_cstr(mrb, element->getStrKey());
mrb_value rval;
std::string typeName = typeid(element->getObject()).name();
auto iter = g_rubyType.find(typeName);
if (g_rubyType.end() != iter) {
className = iter->second;
if (nullptr != dynamic_cast<Ref*>(element->getObject())) {
rval = to_mrb_value(mrb, element->getObject());
}
} else if((strVal = dynamic_cast<__String *>(element->getObject()))) {
rval = mrb_str_new_cstr(mrb, strVal->getCString());
} else if ((dictVal = dynamic_cast<__Dictionary*>(element->getObject()))) {
rval = dictionary_to_rubyval(mrb, dictVal);
} else if ((arrVal = dynamic_cast<__Array*>(element->getObject()))) {
rval = array_to_rubyval(mrb, arrVal);
} else if ((doubleVal = dynamic_cast<__Double*>(element->getObject()))) {
rval = mrb_float_value(mrb, (mrb_float)doubleVal->getValue());
} else if ((floatVal = dynamic_cast<__Float*>(element->getObject()))) {
rval = mrb_float_value(mrb, (mrb_float)floatVal->getValue());
} else if ((intVal = dynamic_cast<__Integer*>(element->getObject()))) {
rval = mrb_fixnum_value((mrb_int)intVal->getValue());
} else if ((boolVal = dynamic_cast<__Bool*>(element->getObject()))) {
rval = mrb_bool_value((mrb_bool)boolVal->getValue());
} else {
CCASSERT(false, "the type isn't suppored.");
}
mrb_hash_set(mrb, rhash, rkey, rval);
}
return rhash;
}