本文整理汇总了C++中DictElement::getObject方法的典型用法代码示例。如果您正苦于以下问题:C++ DictElement::getObject方法的具体用法?C++ DictElement::getObject怎么用?C++ DictElement::getObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DictElement
的用法示例。
在下文中一共展示了DictElement::getObject方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: handshakeResponse
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: 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()));
}
}
}
示例4: snapshotTextures
Dictionary* TextureCache::snapshotTextures()
{
Dictionary* pRet = new Dictionary();
DictElement* pElement = NULL;
CCDICT_FOREACH(_textures, pElement)
{
pRet->setObject(pElement->getObject(), pElement->getStrKey());
}
示例5: 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();
}
示例6: 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);
}
示例7: 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();
}
示例8: loadConfigFile
//
// 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());
}
}
示例9: 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);
}
}
示例10: 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;
}
}
示例11: 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);
}
}
示例12: 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);
}
}
示例13: EquipInit
//.........这里部分代码省略.........
up_layout->setTag(EQUIP_LAYOUT_TAG_UP);
// switch button
// close button
Button* clothes_btn = dynamic_cast<Button*>(up_layout->getChildByName("clothes_button"));
clothes_btn->addTouchEventListener(this, toucheventselector(CocosGUIExamplesEquipScene::switchBtnCallBack));
clothes_btn->setTag(EQUIP_SWITCH_LAYOUT_BUTTON_TAG_CLOTHES);
clothes_btn->setBright(false);
// weapons button
Button* weapons_btn = dynamic_cast<Button*>(up_layout->getChildByName("weapons_button"));
weapons_btn->addTouchEventListener(this, toucheventselector(CocosGUIExamplesEquipScene::switchBtnCallBack));
weapons_btn->setTag(EQUIP_SWITCH_LAYOUT_BUTTON_TAG_WEAPONS);
// pets button
Button* pets_btn = dynamic_cast<Button*>(up_layout->getChildByName("pets_button"));
pets_btn->addTouchEventListener(this, toucheventselector(CocosGUIExamplesEquipScene::switchBtnCallBack));
pets_btn->setTag(EQUIP_SWITCH_LAYOUT_BUTTON_TAG_PETS);
// repertories
// clothes layout
Layout* clothes_layout = dynamic_cast<Layout*>(equipe_root->getChildByName("clothes_panel"));
clothes_layout->setTag(EQUIP_LAYOUT_TAG_CLOTHES);
// weapons layout
Layout* weapons_layout = dynamic_cast<Layout*>(equipe_root->getChildByName("weapons_panel"));
weapons_layout->setTag(EQUIP_LAYOUT_TAG_WEAPONS);
// pets layout
Layout* pets_layout = dynamic_cast<Layout*>(equipe_root->getChildByName("pets_panel"));
pets_layout->setTag(EQUIP_LAYOUT_TAG_PETS);
container_1_Zorder = clothes_layout->getZOrder();
container_2_Zorder = weapons_layout->getZOrder();
container_3_Zorder = pets_layout->getZOrder();
container_1_Position = clothes_layout->getPosition();
container_2_Position = weapons_layout->getPosition();
container_3_Position = pets_layout->getPosition();
// clothes repertory slot
for (auto& obj : clothes_layout->getChildren())
{
Widget* child = dynamic_cast<Widget*>(obj);
m_dicClothesSlot->setObject(child, child->getName());
}
// weapons repertory slot
for (auto& obj : weapons_layout->getChildren())
{
Widget* child = dynamic_cast<Widget*>(obj);
m_dicWeaponsSlot->setObject(child, child->getName());
}
// pets repertory slot
for (auto& obj : pets_layout->getChildren())
{
Widget* child = dynamic_cast<Widget*>(obj);
m_dicPetsSlot->setObject(child, child->getName());
}
// actor
ImageView* wallBG_iv = dynamic_cast<ImageView*>(up_layout->getChildByName("wall"));
ImageView* wal_iv = ImageView::create();
wal_iv->loadTexture("cocosgui/gui_examples/equip_1/equip/eg/1.png");
wal_iv->setAnchorPoint(Point(0.5, 0.5));
float wal_x = wallBG_iv->getSize().width / 2.04;
float wal_y = wallBG_iv->getSize().height / 2.4;
wal_iv->setPosition(Point((-wallBG_iv->getSize().width / 2) + wal_x,
(-wallBG_iv->getSize().height / 2) + wal_y));
wallBG_iv->addChild(wal_iv);
// original clothes be used slot
ImageView* originalClothesSlot_iv = dynamic_cast<ImageView*>(up_layout->getChildByName("1"));
ImageView* originalClothes_iv = ImageView::create();
originalClothes_iv->loadTexture("cocosgui/gui_examples/equip_1/equip/eg/6.png");
originalClothesSlot_iv->addChild(originalClothes_iv);
m_dicBeUsedSlot->setObject(originalClothesSlot_iv, originalClothesSlot_iv->getName());
// other be used slot
ImageView* slot_2_iv = dynamic_cast<ImageView*>(up_layout->getChildByName("2"));
m_dicBeUsedSlot->setObject(slot_2_iv, slot_2_iv->getName());
ImageView* slot_3_iv = dynamic_cast<ImageView*>(up_layout->getChildByName("3"));
m_dicBeUsedSlot->setObject(slot_3_iv, slot_3_iv->getName());
ImageView* slot_4_iv = dynamic_cast<ImageView*>(up_layout->getChildByName("4"));
m_dicBeUsedSlot->setObject(slot_4_iv, slot_4_iv->getName());
ImageView* slot_5_iv = dynamic_cast<ImageView*>(up_layout->getChildByName("5"));
m_dicBeUsedSlot->setObject(slot_5_iv, slot_5_iv->getName());
ImageView* slot_6_iv = dynamic_cast<ImageView*>(up_layout->getChildByName("6"));
m_dicBeUsedSlot->setObject(slot_6_iv, slot_6_iv->getName());
// equip create
create();
// initialize touch able and influence children
DictElement* element = NULL;
clothes_layout->setTouchEnabled(true);
CCDICT_FOREACH(m_dicClothesSlot, element)
{
Widget* child = dynamic_cast<Widget*>(element->getObject());
child->setTouchEnabled(true);
}
开发者ID:6520874,项目名称:CocoStudioSamplesBasedOnCocos2d-x3.0,代码行数:101,代码来源:CocosGUIExamplesEquipScene.cpp
示例14: CCAssert
void GB2ShapeCache::addShapesWithFile(const std::string &plist) {
std::string fullName = FileUtils::getInstance()->fullPathForFilename(plist);
__Dictionary* dict = __Dictionary::createWithContentsOfFile(fullName.c_str());
CCAssert(dict != NULL, "Shape-file not found"); // not triggered - cocos2dx delivers empty dict if non was found
CCAssert(dict->count() != 0, "plist file empty or not existing");
__Dictionary *metadataDict = (__Dictionary *)dict->objectForKey("metadata");
int format = static_cast<__String *>(metadataDict->objectForKey("format"))->intValue();
ptmRatio = static_cast<__String *>(metadataDict->objectForKey("ptm_ratio"))->floatValue();
CCAssert(format == 1, "Format not supported");
__Dictionary *bodyDict = (__Dictionary *)dict->objectForKey("bodies");
b2Vec2 vertices[b2_maxPolygonVertices];
DictElement* pElement;
std::string bodyName;
__Dictionary *bodyData;
CCDICT_FOREACH(bodyDict,pElement){
bodyName = pElement->getStrKey();
bodyData =(__Dictionary*)pElement->getObject();
BodyDef *bodyDef = new BodyDef();
bodyDef->anchorPoint = PointFromString(static_cast<__String *>(bodyData->objectForKey("anchorpoint"))->getCString());
__Array *fixtureList = (__Array *)(bodyData->objectForKey("fixtures"));
FixtureDef **nextFixtureDef = &(bodyDef->fixtures);
Ref* object;
CCARRAY_FOREACH(fixtureList, object){
b2FixtureDef basicData;
__Dictionary *fixtureData = (__Dictionary*)object;
basicData.filter.categoryBits = static_cast< __String*>(fixtureData->objectForKey("filter_categoryBits"))->intValue();
basicData.filter.maskBits = static_cast<__String*>(fixtureData->objectForKey("filter_maskBits"))->intValue();
basicData.filter.groupIndex = static_cast<__String *>(fixtureData->objectForKey("filter_groupIndex"))->intValue();
basicData.friction = static_cast<__String *>(fixtureData->objectForKey("friction"))->floatValue();
basicData.density = static_cast<__String *>(fixtureData->objectForKey("density"))->floatValue();
basicData.restitution = static_cast<__String *>(fixtureData->objectForKey("restitution"))->floatValue();
basicData.isSensor = (bool)static_cast<__String *>(fixtureData->objectForKey("isSensor"))->boolValue();
__String *cb = static_cast<__String *>(fixtureData->objectForKey("userdataCbValue"));
int callbackData = 0;
if (cb)
callbackData = cb->intValue();
std::string fixtureType = static_cast<__String *>(fixtureData->objectForKey("fixture_type"))->getCString();
if (fixtureType == "POLYGON") {
__Array *polygonsArray = (__Array *)(fixtureData->objectForKey("polygons"));
Ref* singlePolygon;
CCARRAY_FOREACH(polygonsArray, singlePolygon){
FixtureDef *fix = new FixtureDef();
fix->fixture = basicData; // copy basic data
fix->callbackData = callbackData;
b2PolygonShape *polyshape = new b2PolygonShape();
int vindex = 0;
__Array *verticeArray = (__Array *)singlePolygon;
assert(verticeArray->count() <= b2_maxPolygonVertices);
Ref* singlePoint;
CCARRAY_FOREACH(verticeArray, singlePoint){
__String* vert = (__String*)singlePoint;
cocos2d::Point offset = PointFromString(vert->getCString());
vertices[vindex].x = (offset.x / ptmRatio) ;
vertices[vindex].y = (offset.y / ptmRatio) ;
vindex++;
}