int CCStoreInventory::getItemBalance(char const *itemId, CCSoomlaError **soomlaError) { CCStoreUtils::logDebug(TAG, CCString::createWithFormat("SOOMLA/COCOS2DX Calling getItemBalance with: %s", itemId)->getCString()); CCDictionary *params = CCDictionary::create(); params->setObject(CCString::create("CCStoreInventory::getItemBalance"), "method"); params->setObject(CCString::create(itemId), "itemId"); CCDictionary *retParams = (CCDictionary *) CCSoomlaNdkBridge::callNative(params, soomlaError); if (retParams == NULL) { return 0; } CCInteger *retValue = (CCInteger *) retParams->objectForKey("return"); if (retValue) { return retValue->getValue(); } else { return 0; } }
std::string CCStoreInventory::getGoodCurrentUpgrade(char const *goodItemId, CCSoomlaError **soomlaError) { CCStoreUtils::logDebug(TAG, CCString::createWithFormat("SOOMLA/COCOS2DX Calling getGoodCurrentUpgrade with: %s", goodItemId)->getCString()); CCDictionary *params = CCDictionary::create(); params->setObject(CCString::create("CCStoreInventory::getGoodCurrentUpgrade"), "method"); params->setObject(CCString::create(goodItemId), "goodItemId"); CCDictionary *retParams = (CCDictionary *) CCSoomlaNdkBridge::callNative(params, soomlaError); if (retParams == NULL) { return ""; } CCString *retValue = (CCString *) retParams->objectForKey("return"); if (retValue) { return retValue->getCString(); } else { return ""; } }
void CCFileUtils::loadFilenameLookupDictionaryFromFile(const char* filename) { std::string fullPath = this->fullPathForFilename(filename); if (fullPath.length() > 0) { CCDictionary* pDict = CCDictionary::createWithContentsOfFile(fullPath.c_str()); if (pDict) { CCDictionary* pMetadata = (CCDictionary*)pDict->objectForKey("metadata"); int version = ((CCString*)pMetadata->objectForKey("version"))->intValue(); if (version != 1) { CCLOG("cocos2d: ERROR: Invalid filenameLookup dictionary version: %ld. Filename: %s", (long)version, filename); return; } setFilenameLookupDictionary((CCDictionary*)pDict->objectForKey("filenames")); } } }
bool InviteRewardCommand::handleRecieve(cocos2d::CCDictionary *dict){ if(dict->valueForKey("cmd")->compare(INVITE_REWARD) != 0) { return false; } CCDictionary *params = _dict(dict->objectForKey("params")); if (!params) { return false; } if (params->objectForKey("errorCode")) { callFail(NetResult::createWithFail(params)); } else { callSuccess(NetResult::createWithSuccess(params)); } CCSafeNotificationCenter::sharedNotificationCenter()->postNotification(MSG_REFREASH_TOOL_DATA); return true; }
bool LotteryActCommand::handleRecieve1(cocos2d::CCDictionary *dict) { CCDictionary* resourceDic = _dict(dict->objectForKey("resource")); if (resourceDic->objectForKey("chip")) { GlobalData::shared()->resourceInfo.lChip = resourceDic->valueForKey("chip")->intValue(); } if (resourceDic->objectForKey("gold")) { GlobalData::shared()->playerInfo.gold = resourceDic->valueForKey("gold")->intValue(); CCSafeNotificationCenter::sharedNotificationCenter()->postNotification(MSG_CITY_RESOURCES_UPDATE); } LotteryController::shared()->lotteryActCmdBack(dict); CCSafeNotificationCenter::sharedNotificationCenter()->postNotification(LOTTERYACTVIEWCMD, NetResult::createWithSuccess(dict)); return true; }
bool InviteInfoCommand::handleRecieve(cocos2d::CCDictionary *dict){ if(dict->valueForKey("cmd")->compare(INVITE_INFO) != 0) { return false; } CCDictionary *params = _dict(dict->objectForKey("params")); if (!params) { return false; } if (params->objectForKey("errorCode")) { callFail(NetResult::createWithFail(params)); } else { callSuccess(NetResult::createWithSuccess(params)); } return true; }
void GameScene::resetGame( ) { CCArray * pArray = (CCArray*)m_pEnemyInfos->objectAtIndex(global::getGameLevel()); CCDictionary * pDic = (CCDictionary*)pArray->objectAtIndex(0); int iBulletNum = pDic->valueForKey("BulletNumber")->intValue(); this->createBullets(iBulletNum); this->attachBullet(); //镜头移动 CCFiniteTimeAction * action1 = CCMoveTo::create(1.5f, ccp(2*-480.0f, 0.0f)); CCDelayTime *action3 = CCDelayTime::create(1.0f); CCFiniteTimeAction *action4 = CCMoveTo::create(1.5f, CCPointZero); runAction(CCSequence::create(action1,action3, action4, NULL)); }
int CCPreLoad::getTotalBytes() { if(!m_dict) return -1; int ret = -1; int total = 0; CCArray* arr = m_dict->allKeys(); if(!arr) return 0; do { unsigned int i; for(i=0; i<arr->count(); ++i) { CCString* p = dynamic_cast<CCString*>(arr->objectAtIndex(i)); if(!p) break; CCDictionary* pdic = dynamic_cast<CCDictionary*>(m_dict->objectForKey(p->getCString())); if(!pdic) break; CCString* p1 = dynamic_cast<CCString*>(pdic->objectForKey("size")); if(!p1) break; total += p1->intValue(); } if(i!=arr->count()) { break; } ret = total; m_tmpTotalBytes = total; }while(0); delete arr; return ret; }
CCNode* CCBReader::readNodeGraphFromData(CCData *pData, CCObject *pOwner, const CCSize &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 CCArray(); mOwnerCallbackNodes = new CCArray(); CCDictionary* animationManagers = CCDictionary::create(); CCNode *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 CCArray(); mAnimationManagersForNodes = new CCArray(); } CCDictElement* pElement = NULL; CCDICT_FOREACH(animationManagers, pElement) { CCNode* pNode = (CCNode*)pElement->getIntKey(); CCBAnimationManager* manager = (CCBAnimationManager*)animationManagers->objectForKey((intptr_t)pNode); pNode->setUserObject(manager); if (jsControlled) { mNodesWithAnimationManagers->addObject(pNode); mAnimationManagersForNodes->addObject(manager); } }
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; } return NULL; }
// on "init" you need to initialize your instance bool HelloWorld::init() { ////////////////////////////// // 1. super init first if ( !CCLayer::init() ) { return false; } _tileMap = CCTMXTiledMap::create("map.tmx"); _background = _tileMap->layerNamed("Background"); this->addChild(_tileMap,-1); CCTMXObjectGroup *objects = _tileMap->objectGroupNamed("object"); CCDictionary *c = objects->objectNamed("SpawnPoint"); CCTMXObjectGroup *group = _tileMap->objectGroupNamed("object"); CCDictionary *spwnPoint = group->objectNamed("SpawnPoint"); int px = spwnPoint->valueForKey("x")->floatValue(); int py = spwnPoint->valueForKey("y")->floatValue(); _player = ShunSprite::create(); _player->setPosition(ccp(px,py)); _tileMap->addChild(_player); this->setViewPointCenter(_player->getPosition()); // CCTMXLayer *wall = _tileMap->layerNamed("wall"); // wall->setVisible(false); _meta = _tileMap->layerNamed("meta"); _meta->setVisible(false); int gid = _background->tileGIDAt(ccp(10,10)); CCLog("backGID:%d",gid); this->registerWithTouchDispatcher(); return true; }
static int tolua_Cocos2dx_CCTableView_create01(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CCTableView",0,&tolua_err) || !tolua_isusertype(tolua_S, 2, "CCSize", 0, &tolua_err) || !tolua_isusertype(tolua_S,3,"CCNode",0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else { LUA_TableViewDataSource* dataSource = new LUA_TableViewDataSource(); if (NULL == dataSource) return 0; CCSize size = *((CCSize*) tolua_tousertype(tolua_S,2,0)); CCNode* node = static_cast<CCNode*>(tolua_tousertype(tolua_S, 3, 0)); CCTableView* tolua_ret = CCTableView::create(dataSource,size,node); if (NULL == tolua_ret) return 0; tolua_ret->reloadData(); CCDictionary* userDict = new CCDictionary(); userDict->setObject(dataSource, KEY_TABLEVIEW_DATA_SOURCE); tolua_ret->setUserObject(userDict); userDict->release(); dataSource->release(); int nID = (int)tolua_ret->m_uID; int* pLuaID = &tolua_ret->m_nLuaID; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CCTableView"); return 1; } return 0; tolua_lerror: return tolua_Cocos2dx_CCTableView_create00(tolua_S); }
bool RPGMapSceneLayer::doMoving(cocos2d::CCPoint targetPoint) { //这里的逻辑跟RPGMapNPCRoleSprite::autoMove类似 CCTMXTiledMap *bgMap = (CCTMXTiledMap*)this->getChildByTag(kRPGMapSceneLayerTagBgMap); RPGMapRoleSprite *player = (RPGMapRoleSprite*)bgMap->getChildByTag(kRPGMapSceneLayerTagPlayer); CCTMXObjectGroup *obstaclesObjects = bgMap->objectGroupNamed("obstacles"); targetPoint = ccpAdd(player->getPosition(), targetPoint); //地图上的障碍物 for (int i = 0; i < obstaclesObjects->getObjects()->count(); i++) { CCDictionary *obstaclesObject = (CCDictionary*)obstaclesObjects->getObjects()->objectAtIndex(i); const CCString *x = obstaclesObject->valueForKey("x"); const CCString *y = obstaclesObject->valueForKey("y"); const CCString *width = obstaclesObject->valueForKey("width"); const CCString *height = obstaclesObject->valueForKey("height"); CCRect obstaclesRect = CCRectMake(stringToNumber<float>(x->getCString()), stringToNumber<float>(y->getCString()), stringToNumber<float>(width->getCString()), stringToNumber<float>(height->getCString())); if(obstaclesRect.containsPoint(targetPoint)) return false; } //NPC或Player for (int i = 0; i < bgMap->getChildren()->count(); i++) { CCObject *item = bgMap->getChildren()->objectAtIndex(i); if(dynamic_cast<RPGMapRoleSprite*>(item) != NULL) { //如果为非player的对象才会执行里面的判断 if(item != player) { if(((RPGMapRoleSprite*)item)->boundingBox().containsPoint(targetPoint)) return false; } } } return true; }
void MutiTouchTestLayer::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent) { CCSetIterator iter = pTouches->begin(); for (; iter != pTouches->end(); iter++) { CCTouch* pTouch = (CCTouch*)(*iter); TouchPoint* pTP = (TouchPoint*)s_dic.objectForKey(pTouch->getID()); CCPoint location = pTouch->getLocation(); pTP->setTouchPos(location); } }
int CCPreLoad::addSingle(const char* pic, int type, int size) { int ret = -1; CCDictionary* dic = new CCDictionary(); CCString* str = new CCString(); CCString* str1 = new CCString(); do{ str->initWithFormat("%d", type); str1->initWithFormat("%d", size); dic->setObject(str1, "size"); dic->setObject(str, "type"); m_dict->setObject(dic, pic); ret = 0; }while(0); dic->release(); str->release(); str1->release(); return ret; }
bool CCStoreInventory::isVirtualGoodEquipped(char const *itemId, CCSoomlaError **soomlaError) { CCStoreUtils::logDebug(TAG, CCString::createWithFormat("SOOMLA/COCOS2DX Calling isVirtualGoodEquipped with: %s", itemId)->getCString()); CCDictionary *params = CCDictionary::create(); params->setObject(CCString::create("CCStoreInventory::isVirtualGoodEquipped"), "method"); params->setObject(CCString::create(itemId), "itemId"); CCDictionary *retParams = (CCDictionary *) CCSoomlaNdkBridge::callNative(params, soomlaError); if (retParams == NULL) { return false; } CCBool *retValue = (CCBool *) retParams->objectForKey("return"); if (retValue) { return retValue->getValue(); } else { return false; } }
void TestFilenameLookup::onEnter() { FileUtilsDemo::onEnter(); CCFileUtils *sharedFileUtils = CCFileUtils::sharedFileUtils(); CCDictionary *dict = CCDictionary::create(); dict->setObject(CCString::create("Images/grossini.png"), "grossini.bmp"); dict->setObject(CCString::create("Images/grossini.png"), "grossini.xcf"); sharedFileUtils->setFilenameLookupDictionary(dict); // Instead of loading carlitos.xcf, it will load grossini.png CCSprite *sprite = CCSprite::create("grossini.xcf"); this->addChild(sprite); CCSize s = CCDirector::sharedDirector()->getWinSize(); sprite->setPosition(ccp(s.width/2, s.height/2)); }
bool CCStoreInventory::nonConsumableItemExists(char const *nonConsItemId, CCSoomlaError **soomlaError) { CCStoreUtils::logDebug(TAG, CCString::createWithFormat("SOOMLA/COCOS2DX Calling nonConsumableItemExists with: %s", nonConsItemId)->getCString()); CCDictionary *params = CCDictionary::create(); params->setObject(CCString::create("CCStoreInventory::nonConsumableItemExists"), "method"); params->setObject(CCString::create(nonConsItemId), "nonConsItemId"); CCDictionary *retParams = (CCDictionary *) CCSoomlaNdkBridge::callNative(params, soomlaError); if (retParams == NULL) { return false; } CCBool *retValue = (CCBool *) retParams->objectForKey("return"); if (retValue) { return retValue->getValue(); } else { return false; } }
void CCBalsamiqLayer::setBalsamiqControl(const std::string &controlType, const std::string &controlName, CCNode *control) { if (controlType.length() == 0 || controlName.length() == 0) { return; } CCObject *controlsDic = this->getBalsamiqControlDic()->objectForKey(controlType); if (controlsDic == NULL) { CCDictionary *dic = CCDictionary::create(); dic->setObject(control, controlName); this->getBalsamiqControlDic()->setObject(dic, controlType); } else { static_cast<CCDictionary *>(controlsDic)->setObject(control, controlName); } }
bool CallbackExplode::doCallback(GameObject * aGameObject,CCDictionary * dic,float dt) { if (dic && aGameObject) { //获得效果本身影响的范围 CCDictionary * property = (CCDictionary *)aGameObject->getValue(KStrProperty); CCString * atkStr = (CCString *)property->objectForKey(KStrATK); CCString * atkRangeStr = (CCString *)property->objectForKey(KStrATK_RANGE); float atk_range_org = (atkRangeStr?atkRangeStr->floatValue():0) * 0.5; float atk = atkStr? atkStr->floatValue() : 0; //获得对应的效果播放的中心点 CCDictionary * pDict=(CCDictionary *)dic->objectForKey(KStrPosition); CCString * paramStr=(CCString *)dic->objectForKey(KStrParam); float scale = !paramStr ? 1.0 : paramStr->floatValue(); float atk_range = scale * atk_range_org; CCPoint p = GameObject::dict2Point(pDict); GameModle * _sharedInstance = GameModle::sharedInstance(); CCDictionary * objects = _sharedInstance->gameObjectsDict(); CCDictElement * pDictElement = NULL; CCDICT_FOREACH(objects, pDictElement){ int32_t classid=pDictElement->getIntKey(); if(KNPCTypeId == GameObject::typeIdOfClassId(classid)){ CCSet * set=(CCSet*)pDictElement->getObject(); CCSetIterator iter; for (iter = set->begin(); iter != set->end(); ++iter) { GameObject * tmp=(GameObject *)(*iter); if (tmp->isActive()) { float r = tmp->getContentSize().width * 0.5; //检测可以攻击到泡泡 if(GameObject::isCircleContact(p,atk_range,tmp->getPosition(),r)){ //处理进入到攻击范围的泡泡 handleExplode(tmp,NULL,atk,aGameObject); } } } } }
void PrettyPrinterDemo::onEnter() { CCLayer::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 28); label->setPosition( ccp(s.width/2, s.height * 4/5) ); this->addChild(label, 1); std::string strSubtitle = subtitle(); if(strSubtitle.empty() == false) { CCLabelTTF* subLabel = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16); subLabel->setPosition( ccp(s.width/2, s.height * 3/5) ); this->addChild(subLabel, 1); } // Test code CCPrettyPrinter vistor; // print dictionary CCDictionary* pDict = CCDictionary::createWithContentsOfFile("animations/animations.plist"); pDict->acceptVisitor(vistor); CCLog("%s", vistor.getResult().c_str()); CCLog("-------------------------------"); CCSet myset; for (int i = 0; i < 30; ++i) { myset.addObject(CCString::createWithFormat("str: %d", i)); } vistor.clear(); myset.acceptVisitor(vistor); CCLog("%s", vistor.getResult().c_str()); CCLog("-------------------------------"); vistor.clear(); addSprite(); pDict = CCTextureCache::sharedTextureCache()->snapshotTextures(); pDict->acceptVisitor(vistor); CCLog("%s", vistor.getResult().c_str()); }
bool GHAnimation::initWithDictionary(CCDictionary* dict, const char* animName) { if(dict == NULL)return false; name = std::string(animName); float delayPerUnit = dict->valueForKey("delayPerUnit")->floatValue(); loop = dict->valueForKey("loop")->boolValue(); randomFrames = dict->valueForKey("randomFrames")->boolValue(); repetitions = dict->valueForKey("loops")->intValue(); maxRandomTime = dict->valueForKey("maxRandomTime")->floatValue(); minRandomTime = dict->valueForKey("minRandomTime")->floatValue(); randomReplay = dict->valueForKey("randomReplay")->boolValue(); restoreSprite = dict->valueForKey("restoreOriginalFrame")->boolValue(); CCArray* framesInfo = (CCArray*)dict->objectForKey("frames"); totalTime = 0; CCObject* pObj = NULL; CCARRAY_FOREACH(framesInfo, pObj) { CCDictionary* frmInfo = (CCDictionary*)pObj; if(frmInfo){ float delay = frmInfo->valueForKey("delayUnits")->floatValue(); float frameTime = delay*delayPerUnit; totalTime += frameTime; GHAnimationFrame* newFrm = GHAnimationFrame::createWithDictionary(frmInfo); if(newFrm){ frames->addObject(newFrm); newFrm->setTime(frameTime); } } }
int GlobalData::sqliteExecCallBack( void * para, int n_column, char ** column_value, char ** column_name ) { const char *myPara = (const char *)para; if (strcmp(myPara, QUERY_CATEGORY_FRACTION)==0) { CCDictionary *dict = CCDictionary::create(); for(int i = 0 ; i < n_column; i ++ ) { dict->setObject(CCString::create(column_value[i]), column_name[i]); } arrayFraction->addObject(dict); } else if(strcmp(myPara, QUERY_CATEGORY_CARDINFO)==0) { dictCard = CCDictionary::create(); for(int i = 0 ; i < n_column; i ++ ) { dictCard->setObject(CCString::create(column_value[i]), column_name[i]); } } else if(strcmp(myPara, QUERY_CATEGORY_CARDBYGROUP)==0) { dictCard = CCDictionary::create(); for(int i = 0 ; i < n_column; i ++ ) { dictCard->setObject(CCString::create(column_value[i]), column_name[i]); } arrayCardProfile->addObject(dictCard); } else if(strcmp(myPara, QUERY_CARD_PROFILE_BY_NAME)==0) { dictCard = CCDictionary::create(); for(int i = 0 ; i < n_column; i ++ ) { dictCard->setObject(CCString::create(column_value[i]), column_name[i]); } } else if(strcmp(myPara, QUERY_CARD_PROFILE_ALL)==0) { dictCard = CCDictionary::create(); for(int i = 0 ; i < n_column; i ++ ) { dictCard->setObject(CCString::create(column_value[i]), column_name[i]); } arrayCards->addObject(dictCard); } return 0; }
void CCPurchasableVirtualItem::putPurchaseTypeToDict(CCDictionary *dict) { CCDictionary *purchasableObj = CCDictionary::create(); if (dynamic_cast<CCPurchaseWithMarket *>(mPurchaseType)) { purchasableObj->setObject(CCString::create(JSON_PURCHASE_TYPE_MARKET), JSON_PURCHASE_TYPE); CCPurchaseWithMarket *purchaseWithMarket = (CCPurchaseWithMarket *)mPurchaseType; CCMarketItem *mi = purchaseWithMarket->getMarketItem(); purchasableObj->setObject(mi->toDictionary(), JSON_PURCHASE_MARKET_ITEM); } else if (dynamic_cast<CCPurchaseWithVirtualItem *>(mPurchaseType)) { CCPurchaseWithVirtualItem *purchaseWithVirtualItem = (CCPurchaseWithVirtualItem *)mPurchaseType; purchasableObj->setObject(CCString::create(JSON_PURCHASE_TYPE_VI), JSON_PURCHASE_TYPE); purchasableObj->setObject(purchaseWithVirtualItem->getItemId(), JSON_PURCHASE_VI_ITEMID); purchasableObj->setObject(purchaseWithVirtualItem->getAmount(), JSON_PURCHASE_VI_AMOUNT); } else { CC_ASSERT(false); } dict->setObject(purchasableObj, JSON_PURCHASABLE_ITEM); }
void JniCall::purchaseByIndex(int index) { InPurchaseData data = gInPurchaseData[index]; #if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32) CCDictionary* dic = CCDictionary::create(); CCString* itemCode = CCString::create(data.itemIndex); CCString *priceValue = CCString::create(data.priceValue); CCString *payAlias = CCString::create(data.rewardValue); dic->setObject(itemCode, "itemCode"); dic->setObject(priceValue, "price"); dic->setObject(payAlias,"payAlias"); SendMessageWithParams("purchase", dic); #else CCDictionary *dic = CCDictionary::create(); dic->setObject(CCString::createWithFormat("%d", atoi(data.itemIndex.c_str())), "itemCode"); dic->setObject(CCString::create(data.priceValue), "price"); purchaseSuccess(NULL, dic); #endif }
void HelloWorld::addWaypoint() { DataModel *m = DataModel::getModel(); CCTMXObjectGroup *objects =_tileMap->objectGroupNamed("Objects"); WayPoint *wp = NULL; int spawnPointCounter = 0; CCDictionary *spawnPoint; while ((spawnPoint =objects ->objectNamed(CCString::createWithFormat("Waypoint%d", spawnPointCounter)->getCString()))) { int x = spawnPoint->valueForKey("x")->intValue(); int y = spawnPoint->valueForKey("y")->intValue(); wp =(WayPoint *)WayPoint::create(); wp->setPosition(ccp(x, y)); m->getWaypoints()->addObject(wp); spawnPointCounter++; } // NSAssert([m->getWaypoints()->count()] > 0, @"Waypoint objects missing"); wp = NULL; }
void GameLayer::loadTowerPositions() { CCArray* towerPositions = CCArray::createWithContentsOfFile("TowersPosition.plist"); CCObject* obj; CCARRAY_FOREACH(towerPositions, obj) { //Converting to actual obj type CCDictionary* towerPos = (CCDictionary*)obj; //Creating sprite at position CCSprite* towerBase = CCSprite::create("open_spot.png"); CCPoint p = ccp(towerPos->valueForKey("x")->intValue(), towerPos->valueForKey("y")->intValue()); towerBase->setPosition(p); //Adding to layer this->addChild(towerBase); //Adding to array towerBases.addObject(towerBase); }
void MutiTouchTestLayer::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent) { CCSetIterator iter = pTouches->begin(); for (; iter != pTouches->end(); iter++) { CCTouch* pTouch = (CCTouch*)(*iter); TouchPoint* pTP = (TouchPoint*)s_dic.objectForKey(pTouch->getID()); CCPoint location = pTouch->locationInView(); location = CCDirector::sharedDirector()->convertToGL(location); pTP->setTouchPos(location); } }
void HNewbieStart::onMaskFadeOutEnd() { m_pMaskLayer->setVisible(false); if (m_selectIndex < 4) { runAction(HGuideChat::create(m_selectIndex+1, m_selectIndex+1)); m_pChatDlg->setPositionY(0); }else{ onBattleFadeEnd(); return; HLoadingWindow::getInstance()->start(); CCDictionary* param = CCDictionary::create(); param->setObject(HString::createWithInteger(0), "PID"); param->setObject(HString::createWithInteger(99999), "MapID"); HDataCenter::post(HDataRequest::create(ACTION_REPLAY_LEVEL+1, param)); } }
void CCPurchasableVirtualItem::fillPurchaseTypeFromDict(CCDictionary *dict) { CCDictionary *purchasableDict = dynamic_cast<CCDictionary *>(dict->objectForKey(JSON_PURCHASABLE_ITEM)); CC_ASSERT(purchasableDict); CCString* purchaseTypeStr = dynamic_cast<CCString *>(purchasableDict->objectForKey(JSON_PURCHASE_TYPE)); CCAssert(purchaseTypeStr != NULL, "invalid object type in dictionary"); if (purchaseTypeStr->compare(JSON_PURCHASE_TYPE_MARKET) == 0) { CCDictionary *marketItemDict = dynamic_cast<CCDictionary *>(purchasableDict->objectForKey(JSON_PURCHASE_MARKET_ITEM)); CC_ASSERT(marketItemDict); setPurchaseType(CCPurchaseWithMarket::createWithMarketItem( CCMarketItem::createWithDictionary(marketItemDict))); } else if (purchaseTypeStr->compare(JSON_PURCHASE_TYPE_VI) == 0) { CCString *itemId = dynamic_cast<CCString *>(purchasableDict->objectForKey(JSON_PURCHASE_VI_ITEMID)); CC_ASSERT(itemId); CCInteger *amount = dynamic_cast<CCInteger *>(purchasableDict->objectForKey(JSON_PURCHASE_VI_AMOUNT)); CC_ASSERT(amount); setPurchaseType(CCPurchaseWithVirtualItem::create(itemId, amount)); } else { CCLog("Couldn't determine what type of class is the given purchaseType."); } }