当前位置: 首页>>代码示例>>C++>>正文


C++ CCArray::count方法代码示例

本文整理汇总了C++中CCArray::count方法的典型用法代码示例。如果您正苦于以下问题:C++ CCArray::count方法的具体用法?C++ CCArray::count怎么用?C++ CCArray::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCArray的用法示例。


在下文中一共展示了CCArray::count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: viewDidLoad

void SGPiecesCell::viewDidLoad()
{
	ResourceManager::sharedInstance()->bindTexture("sgstorysectionlayer/sgstorysectionlayer.plist", RES_TYPE_LAYER_UI, m_tag);
	ResourceManager::sharedInstance()->bindTexture("sgpvpmainlayer/sgpvpmainlayer.plist", RES_TYPE_LAYER_UI, m_tag);
	ResourceManager::sharedInstance()->bindTexture("sgpieceslayer/sgpieceslayer.plist", RES_TYPE_LAYER_UI, m_tag);
	ResourceManager::sharedInstance()->bindTexture("sgcardslayer/sgcardslayer.plist", RES_TYPE_LAYER_UI, m_tag);
	ResourceManager::sharedInstance()->bindTexture("sgstrenglayer/sgstrenglayer.plist", RES_TYPE_LAYER_UI, m_tag, LIM_PNG_AS_PNG);

	
	char officerName[256] = "\0";
	int shift = 0;// 名称黑色背景右向偏移
	
	int iconId = -1;
	if (info->getItemType() == 0)//武将
	{
		SGOfficerDataModel *temp = SGStaticDataManager::shareStatic()->getOfficerById(info->getCallCardId());
		iconId = temp->getIconId();
	}
	else if (info->getItemType() == 1)//装备
	{
		SGEquipmentDataModel *temp =SGStaticDataManager::shareStatic()->getEquipById(info->getCallCardId());
		iconId = temp->getIconId();
	}
	
	SGMainManager::shareMain()->addHeadIconPlistByNum(iconId,sg_piecesLayer);
	sprintf(officerName, "head%d.png", iconId);
	
	shift = 10;
	
	//设置cell上的头像
	CCSprite *piecesHead = CCSprite::createWithSpriteFrameName(officerName);
    piecesHead->setTag(HEAD_TAG);
	piecesHead->setPosition(ccp(-bgSize.width/2+ZoomInX(20), 2));
	this->addChild(piecesHead);
	
	//品质框
    SGPiecesDataModel *pieces = SGStaticDataManager::shareStatic()->getPiecesDictById(info->getItemId());
    int starlvl = pieces->getStarLevel();
    if (starlvl > 1) //策划表的蓝色为4,但是客户端的图形里标识为3,需要减1。
    {
        starlvl -= 1;
    }
    
	char pinzhi[256] = "\0";
	
	if (info->getItemType() == 0)
	{
		sprintf(pinzhi, "officerPinzhi_%d_0.png",starlvl);
	}
	else if (info->getItemType() == 1)
	{
		sprintf(pinzhi, "equipPinzhi_%d_0.png", starlvl);
	}
	
	CCSprite *pz = CCSprite::createWithSpriteFrameName(pinzhi);
    pz->setTag(PINZHI_TAG);
	this->addChild(pz);
	pz->setPosition(piecesHead->getPosition());
	
	
	//头像蒙版
	CCSprite *headMask = CCSprite::createWithSpriteFrameName("pieces_mask.png");
	this->addChild(headMask);
	headMask->setPosition(piecesHead->getPosition());
	
	int piecesCommonNum = 0;
	CCArray *piecesArray = SGPlayerInfo::sharePlayerInfo()->getPiecesCommonCards();
	if (piecesArray->data && piecesArray->data->arr && piecesArray->count())
	{
		piecesCommonNum = ((SGPiecesCard *)piecesArray->objectAtIndex(0))->getPiecesCurNum();//能使用的通用碎片
	}
	
    CCSprite * bg = CCSprite::createWithSpriteFrameName("item_bigbg.png");
    this->addChild(bg,-5);
	//名称黑色背景
	CCSprite *namebg = CCSprite::createWithSpriteFrameName("name_bg.png");
	namebg->setPosition(ccp(piecesHead->getPositionX() + piecesHead->getContentSize().width * 1.35 + shift,  20));
    this->addChild(namebg, 0);
	
	//设置碎片名称
	piecesName = SGCCLabelTTF::create(info->getPiecesName()->getCString(), FONT_BOXINFO, 25);
	piecesName->setAnchorPoint(ccp(0,0.5));
	piecesName->setPosition(ccp(headMask->getPositionX() + headMask->getContentSize().width / 2 + 10, namebg->getPositionY()));
	this->addChild(piecesName, 1);
	
	totalAndCurProgress = SGCCLabelTTF::create(CCString::createWithFormat(str_PiecesCell_str4, info->getPiecesCurNum())->getCString(), FONT_BOXINFO, 23);
    totalAndCurProgress->setAnchorPoint(ccp(0, 0.5));
//	totalAndCurProgress->setPosition(ccp(15 + prog->getPosition().x + prog->getContentSize().width, prog->getPosition().y));
    totalAndCurProgress->setPosition(ccp( piecesName->getPosition().x , piecesName->getPositionY() - 25 ));
	this->addChild(totalAndCurProgress);
//	if (info->getPiecesCurNum() >= info->getSummonNeed())//拥有的碎片数能召唤
//	{
//		totalAndCurProgress->setInsideColor(COLOR_GREEN);
//	}
//	else
//	{
//		totalAndCurProgress->setInsideColor(ccWHITE);
//	}
}
开发者ID:caoguoping,项目名称:warCraft,代码行数:99,代码来源:SGPiecesCell.cpp

示例2: initWithImageData

bool GAFAsset::initWithImageData(const std::string& jsonPath)
{
	if (!s3eFileCheckExists(jsonPath.c_str()))
	{
		GAFLOGERROR("CAN NOT create GAFAsset : %s does not exists", jsonPath.c_str());
		return false;
	}
	GAFData aConfigData;
	//std::string fp = CCFileUtils::sharedFileUtils()->fullPathForFilename(jsonPath.c_str());
	std::string fp = jsonPath;
	s3eFile * file = s3eFileOpen (fp.c_str(), "rb");
	if (!file)
	{
		GAFLOGERROR("CAN NOT create GAFAsset : can not open %s.", fp.c_str());
		return false;
	}
	
	aConfigData.setSize(s3eFileGetSize(file));
	aConfigData.setBytes(new unsigned char[aConfigData.size()]);
	s3eFileRead(aConfigData.bytes(), aConfigData.size(), 1, file);
	s3eFileClose(file);
	aConfigData.setDeleteData(true);

	if (!aConfigData.bytes())
	{
		GAFLOGERROR("Can not get data from json file : %s", jsonPath.c_str());
		return NULL;
	}

	if (!aConfigData.bytes())
	{
		GAFLOGWARN("can not init GAFAsset - invalid anImageData");
		return false;
	}
	
	CCDictionary* configDictionary = CCJSONConverter::sharedConverter()->dictionaryFrom( (const char *)aConfigData.bytes());
	
	CCString *versionNode               = (CCString*)configDictionary->objectForKey(kVersionKey);
	
	if (!isAssetVersionPlayable(versionNode->getCString()))
	{
		return false;
	}
	CCArray *animationConfigFrames      = (CCArray *)configDictionary->objectForKey(kAnimationConfigFramesKey);
	CCArray *interactionObjectNodes     = (CCArray *)configDictionary->objectForKey(kInteractionObjectsKey);
	CCArray *standObjectsNodes          = (CCArray *)configDictionary->objectForKey(kStandObjectsKey);
	CCArray *textureAtlasNode           = (CCArray *)configDictionary->objectForKey(kTextureAtlasKey);
	CCArray *animationSequences         = (CCArray *)configDictionary->objectForKey(kAnimationSequencesKey);
	
	CCDictionary *objectNodes           = (CCDictionary *)configDictionary->objectForKey(kAnimationObjectsKey);
	CCDictionary *masksNodes            = (CCDictionary *)configDictionary->objectForKey(kAnimationMasksKey);
	CCDictionary *namedPartsNodes       = (CCDictionary *)configDictionary->objectForKey(kAnimationNamedPartsKey);

	
	if (!animationConfigFrames || !textureAtlasNode|| !objectNodes)
	{
		GAFLOGERROR("Error while creating GAFAsset. Required subnodes in dictionary are missing.");
		return false;
	}
	
	CC_SAFE_RELEASE(_textureAtlas);
	
	if (!textureAtlasNode->count())
	{
		return false;
	}

	CCDictionary * atlasDictionary = (CCDictionary *)textureAtlasNode->objectAtIndex(0);
	float atlasScale = atlasScaleFromAtlasConfig(atlasDictionary);
	for (int i = 1; i < textureAtlasNode->count(); ++i)
	{
		CCDictionary * a = (CCDictionary *)textureAtlasNode->objectAtIndex(i);
		float as = atlasScaleFromAtlasConfig(a);
		if ( fabs(atlasScale - _currentDeviceScale) > fabs(as - _currentDeviceScale))
		{
			atlasDictionary = a;
			atlasScale = as;
		}
	}
	
	_usedAtlasContentScaleFactor = atlasScale;
	CCArray * atlasesInfo = (CCArray *)atlasDictionary->objectForKey(kAtlasInfoKey);
	if (!atlasesInfo)
	{
		GAFLOGERROR("Error while creating GAFAsset.atlasesInfo subnode is missing in atlasDictionary.");
		return false;
	}
	
	_textureAtlas = GAFTextureAtlas::create(fp.c_str(), atlasDictionary);
	if (!_textureAtlas)
	{
		GAFLOGERROR("Failed to initialize GAFAsset. GAFTextureAtlas could not be created.");
		return false;
	}
	CC_SAFE_RETAIN(_textureAtlas);
	
	if (_objects != objectNodes)
	{
		CC_SAFE_RELEASE(_objects);
		_objects = objectNodes;
//.........这里部分代码省略.........
开发者ID:digitalassetgroup,项目名称:-BIBS-Game,代码行数:101,代码来源:GAFAsset.cpp

示例3: step

void PhysicsWorld::step(float deltaTime)
{
    //TODO:
    /*
     how to clear out friction? currently, no friction
     */
    Player* player = GlobalEngine::sharedGlobalEngine()->getPlayer();
    CCArray* planets = GlobalEngine::sharedGlobalEngine()->getLevelMapLayer()->getPlanets();
    
    //add gravity
    b2Vec2 force;
    force.SetZero();
    
    b2Body* playerBody = player->getB2Body();
    
    if (player->isGrounded() && player->getCurrentGround()->getType() == GameObjectTypePlanet)
    {
        //only apply gravity of current planet
        force = getGravity(player, (Planet*)player->getCurrentGround());
    }
    else
    {
        for (int i = 0; i < planets->count(); i++)
        {
            force += getGravity(player, (Planet*)planets->objectAtIndex(i));
        }
    }
    
    //rotate to gravity
    float angle = atan2(force.y, force.x) + b2_pi / 2.0f;
    playerBody->SetTransform(playerBody->GetPosition(), angle);
    
    playerBody->ApplyForceToCenter(force);
    
    //apply movement by force
    /*b2Vec2 localForce;
     switch (_player->getMoveState()) {
     case PlayerMoveStateLeft:
     localForce.Set(-PLAYER_MOVE_FORCE, 0);
     break;
     
     case PlayerMoveStateRight:
     localForce.Set(PLAYER_MOVE_FORCE, 0);
     break;
     
     default:
     localForce.SetZero();
     break;
     }
     
     b2Rot rotation(angle);
     b2Vec2 globalForce = b2Mul(rotation, localForce);
     playerBody->ApplyForceToCenter(globalForce);
     
     //b2Vec2 impulse = globalSpeed - playerBody->GetLinearVelocity();
     //impulse *= playerBody->GetMass();
     //playerBody->ApplyLinearImpulse(impulse, playerBody->GetWorldCenter());
     */
    
    
    //apply movement by impulse
    if (player->isGrounded() && player->getJumpState() != PlayerJumpStateLeaving)
    {
        b2Vec2 localSpeed;
        switch (player->getMoveState()) {
            case PlayerMoveStateLeft:
                localSpeed.Set(-PLAYER_MOVE_SPEED, 0);
                break;
                
            case PlayerMoveStateRight:
                localSpeed.Set(PLAYER_MOVE_SPEED, 0);
                break;
                
            default:
                localSpeed.SetZero();
                break;
        }
        
        b2Rot rotation(angle);
        b2Vec2 globalSpeed = b2Mul(rotation, localSpeed);
        b2Vec2 impulse = globalSpeed - playerBody->GetLinearVelocity();
        impulse *= playerBody->GetMass();
        
        playerBody->ApplyLinearImpulse(impulse, playerBody->GetWorldCenter());
    }
    
    //apply jumping
    if (player->getJumpState() == PlayerJumpStatePending)
    {
        player->setJumpState(PlayerJumpStateLeaving);
        
        if (player->isGrounded())
        {
            b2Vec2 localJumpSpeed;
            localJumpSpeed.Set(PLAYER_JUMP_SPEED, 0);
            b2Rot jumpRotation(angle + b2_pi / 2.0f);
            b2Vec2 globalJumpSpeed = b2Mul(jumpRotation, localJumpSpeed);
            b2Vec2 jumpImpulse = globalJumpSpeed;
            jumpImpulse *= playerBody->GetMass();
            
//.........这里部分代码省略.........
开发者ID:wandermyz,项目名称:CATLIEN,代码行数:101,代码来源:PhysicsWorld.cpp

示例4: updatePiecesCard

//滑动时更新cell
void SGPiecesCell::updatePiecesCard(SGPiecesCard *card)
{
    ResourceManager::sharedInstance()->bindTexture("sgpieceslayer/sgpieceslayer.plist", RES_TYPE_LAYER_UI, sg_piecesLayer);
    
    char officerName[256] = "\0";
	int shift = 0;// 名称黑色背景右向偏移
	
	int iconId = -1;
	if (card->getItemType() == 0)//武将
	{
		SGOfficerDataModel *temp = SGStaticDataManager::shareStatic()->getOfficerById(card->getCallCardId());
		iconId = temp->getIconId();
	}
	else if (card->getItemType() == 1)//装备
	{
		SGEquipmentDataModel *temp =SGStaticDataManager::shareStatic()->getEquipById(card->getCallCardId());
		iconId = temp->getIconId();
	}
	
	SGMainManager::shareMain()->addHeadIconPlistByNum(iconId,sg_piecesLayer);
	sprintf(officerName, "head%d.png", iconId);
	
	shift = 10;
	
	//滑动过后重置cell上的头像
	CCSprite *piecesHeadTemp = CCSprite::createWithSpriteFrameName(officerName);
    static_cast<CCSprite *>(this->getChildByTag(HEAD_TAG))->setDisplayFrame(piecesHeadTemp->displayFrame());
    
	
	//滑动过后的品质框
	char pinzhi[256] = "\0";
	
	if (card->getItemType() == 0)
	{
		SGOfficerDataModel *temp = SGStaticDataManager::shareStatic()->getOfficerById(card->getCallCardId());
		int starlvl = temp->getOfficerCurrStarLevel();
		if (starlvl>1)
        {
			starlvl-=1;
		}
		sprintf(pinzhi, "officerPinzhi_%d_0.png",starlvl);
	}
	else if (card->getItemType() == 1)
	{
		SGEquipmentDataModel *equipModel = SGStaticDataManager::shareStatic()->getEquipById(info->getCallCardId());
		sprintf(pinzhi, "equipPinzhi_%d_0.png", equipModel->getEquipStarPinzhi());
	}
	
    //更新的时候重围品质框
	CCSprite *pzTemp = CCSprite::createWithSpriteFrameName(pinzhi);
    static_cast<CCSprite *>(this->getChildByTag(PINZHI_TAG))->setDisplayFrame(pzTemp->displayFrame());
	
    //头像蒙版不需要更新
	
    
	int addCommonPieces = 0;//加到当前碎片数上,值由isUseCommon来决定是0,还是可使用的通用碎片数
	int piecesCommonNum = 0;
	CCArray *piecesArray = SGPlayerInfo::sharePlayerInfo()->getPiecesCommonCards();
	if (piecesArray->data && piecesArray->data->arr && piecesArray->count())
	{
		piecesCommonNum = ((SGPiecesCard *)piecesArray->objectAtIndex(0))->getPiecesCurNum();//能使用的通用碎片
	}
	
	//重置碎片名称
    piecesName->setString(card->getPiecesName()->getCString());
    
    
	//更新显示进度
    totalAndCurProgress->setString(CCString::createWithFormat(str_PiecesCell_str4, card->getPiecesCurNum())->getCString());
    
//	if (card->getPiecesCurNum() >= card->getSummonNeed())//拥有的碎片数能召唤
//	{
//		totalAndCurProgress->setInsideColor(COLOR_GREEN);
//	}
//	else
//	{
//		totalAndCurProgress->setInsideColor(ccWHITE);
//	}
}
开发者ID:caoguoping,项目名称:warCraft,代码行数:80,代码来源:SGPiecesCell.cpp

示例5: GetMapInfo

void CFrontground::GetMapInfo()
{
	if ( m_pCrashRectArray )
		m_pCrashRectArray->release();
	m_pCrashRectArray	= m_pTileMap->objectGroupNamed("pengzhuang")->getObjects();
	m_pCrashRectArray->retain();
	if ( m_pCrashTriaArray )
		m_pCrashTriaArray->release();
	m_pCrashTriaArray	= m_pTileMap->objectGroupNamed("zuobiao3")->getObjects();
	m_pCrashTriaArray->retain();
	if ( m_unLevel < 49 )
		m_pTileMap->reorderChild((CCSpriteBatchNode*)m_pTileMap->getChildren()->objectAtIndex(3),5);
	else if ( m_unLevel < 55 )
	{
		m_pTileMap->reorderChild((CCSpriteBatchNode*)m_pTileMap->getChildren()->objectAtIndex(1),0);
		m_pTileMap->reorderChild((CCSpriteBatchNode*)m_pTileMap->getChildren()->objectAtIndex(2),1);
		m_pTileMap->reorderChild((CCSpriteBatchNode*)m_pTileMap->getChildren()->objectAtIndex(3),1);
		m_pTileMap->reorderChild((CCSpriteBatchNode*)m_pTileMap->getChildren()->objectAtIndex(4),2);
		m_pTileMap->reorderChild((CCSpriteBatchNode*)m_pTileMap->getChildren()->objectAtIndex(5),2);
		m_pTileMap->reorderChild((CCSpriteBatchNode*)m_pTileMap->getChildren()->objectAtIndex(6),5);
		m_pTileMap->reorderChild((CCSpriteBatchNode*)m_pTileMap->getChildren()->objectAtIndex(7),5);
	}

	if ( m_pObjectArray )
	{
		delete[] m_pObjectArray;
		m_pObjectArray = NULL;
	}
	CCArray* pObjectArray = m_pTileMap->objectGroupNamed("zuobiao1")->getObjects();
	m_unObjectArrayNum = pObjectArray->count();
	if ( m_unObjectArrayNum )
	{
		m_pObjectArray = new MapObject[m_unObjectArrayNum];
		for ( int i = 0; i < m_unObjectArrayNum; i++ )
		{
			CCDictionary* pObject = (CCDictionary*)pObjectArray->objectAtIndex(i);
			int kind = pObject->valueForKey("id")->uintValue();
			m_pObjectArray[i].unKind	= kind;
			m_pObjectArray[i].x			= pObject->valueForKey("x")->floatValue();
			m_pObjectArray[i].y			= pObject->valueForKey("y")->floatValue();

			switch ( kind )
			{
			case 0:
				m_pObjectArray[i].iToward = pObject->valueForKey("type")->uintValue();
				m_pObjectArray[i].argi1 = pObject->valueForKey("index")->intValue();
				m_pObjectArray[i].argi2 = pObject->valueForKey("add")->intValue();
				m_pObjectArray[i].argi3 = pObject->valueForKey("num")->intValue();
				m_pObjectArray[i].w		= 170;
				m_pObjectArray[i].h		= 800;
				m_pObjectArray[i].argb	= false;
				m_pObjectArray[i].argb1	= false; 
				m_pObjectArray[i].bCheck= false;
				break;
			case 1:
				m_pObjectArray[i].sPath = g_sBoxPath[pObject->valueForKey("type")->uintValue()];
				m_pObjectArray[i].arg1	= 0;
				if ( m_unLevel < 0 )
					m_pObjectArray[i].argi3 = pObject->valueForKey("item")->intValue();
				break;
			case 2:
				m_pObjectArray[i].sPath = g_sStairPath[pObject->valueForKey("type")->uintValue()-1];
				m_pObjectArray[i].argi1 = pObject->valueForKey("type")->uintValue() - 1;
				m_pObjectArray[i].arg1	= m_pObjectArray[i].x;
				m_pObjectArray[i].arg2	= pObject->valueForKey("max")->floatValue();
				m_pObjectArray[i].arg3	= 2.0;
				m_pObjectArray[i].bCheck= true;
				break;
			case 3:
				m_pObjectArray[i].sPath = g_sStairPath[pObject->valueForKey("type")->uintValue()-1];
				m_pObjectArray[i].argi1 = pObject->valueForKey("type")->uintValue() - 1;
				m_pObjectArray[i].arg1	= m_pObjectArray[i].y;
				m_pObjectArray[i].arg2	= pObject->valueForKey("max")->floatValue();
				m_pObjectArray[i].arg3	= 2.0;
				m_pObjectArray[i].bCheck= true;
				break;
			case 4:
				m_pObjectArray[i].sPath = "Tile/a3.png";
				m_pObjectArray[i].argi1 = 0;
				m_pObjectArray[i].argb	= false;
				m_pObjectArray[i].bCheck= true;
				break;
			case 5:
				m_pObjectArray[i].sPath = "Tile/a4.png";
				m_pObjectArray[i].argi1 = 0;
				break;
			case 6:
				m_pObjectArray[i].sPath = g_sStairPath[pObject->valueForKey("type")->uintValue()-1];
				m_pObjectArray[i].argi1 = pObject->valueForKey("type")->uintValue() - 1;
				m_pObjectArray[i].arg1	= m_pObjectArray[i].x;
				m_pObjectArray[i].arg2	= pObject->valueForKey("to")->floatValue();
				m_pObjectArray[i].arg3	= 2.0;
				m_pObjectArray[i].bCheck= true;
				if ( m_pObjectArray[i].arg2 == 0.0 )
					m_pObjectArray[i].iToward = 1;
				else
					m_pObjectArray[i].iToward = -1;
				break;
			case 7:
				m_pObjectArray[i].argi1	= pObject->valueForKey("type")->intValue();
//.........这里部分代码省略.........
开发者ID:bo-jwolf,项目名称:project,代码行数:101,代码来源:Frontground.cpp

示例6: initMsg

void SGGeneralsLayer::initMsg()
{
    SGCardItem::addCardItemRes(sg_generalsLayer);//添加item资源
//    tableViewColumns = 5;
    
    tableViewHeight = 120;


    _allData = CCArray::create();
     _allData->retain();
    CCArray *array =CCArray::create();
    array->retain();
    array =SGPlayerInfo::sharePlayerInfo()->getOfficerCards();
    ;
    for (int i=0;i<6;i++) {
        stars[i]=0;
    }
    for(int i=0;i<array->count();i++)//统计素材每个星级的数量
    {
        SGBaseMilitaryCard *baseMilitaryCard = (SGBaseMilitaryCard *)array->objectAtIndex(i);
//        CCString *str_ = CCString::create(baseMilitaryCard->getClassName());
//        if (str_->isEqual(CCString::create("SGOfficerCard")))
//        {
        SGOfficerCard *card = (SGOfficerCard *)baseMilitaryCard;
        int po1 = SGTeamgroup::shareTeamgroupInfo()->getPositionId(1,card);
        int po2 = SGTeamgroup::shareTeamgroupInfo()->getPositionId(2,card);
        int po3 = SGTeamgroup::shareTeamgroupInfo()->getPositionId(3,card);
        if ( po1 == 0 && po2 ==0 && po3 == 0 && card->getIsProt() == 0)
        {
            int s = card->getCurrStar()-1;
            stars[s]+=1;
        }

//        }
    }

   
    for(int i=0;i<array->count();i++)
    {
        if (enterType==4) {//首页-强化-主将计
            SGSkillDataModel *lordSkill = SGStaticDataManager::shareStatic()->getLordSkillById(((SGOfficerCard *)array->objectAtIndex(i))->getLordId());
            if(lordSkill && lordSkill->getNextId() && ((SGOfficerCard *)array->objectAtIndex(i))->getLordMaxLevel()>lordSkill->getLevel())
            _allData->addObject(array->objectAtIndex(i));
            
        }
        else if (enterType==5)//首页-强化-武将计
        {
            SGSkillDataModel *officerSkill = SGStaticDataManager::shareStatic()->getGeneralSkillById(((SGOfficerCard *)array->objectAtIndex(i))->getOfficerSkil());
            if (officerSkill && officerSkill->getNextId() && ((SGOfficerCard *)array->objectAtIndex(i))->getSkillMaxLevel()>officerSkill->getSkillMaxLevel()) {
                 _allData->addObject(array->objectAtIndex(i));
            }
        }
        else if (enterType ==2)//首页-强化按键-强化武将
        {
            if (((SGOfficerCard *)array->objectAtIndex(i))->getCurrLevel() < ((SGOfficerCard *)array->objectAtIndex(i))->getMaxLevel())
            {
                _allData->addObject(array->objectAtIndex(i));
            }

        }
        else if(enterType == 3)//首页-转生-武将
        {
            SGOfficerCard *card = (SGOfficerCard *)array->objectAtIndex(i);
            int usednum = 0;
            
            if (card->getMaxStar())
            {
                if (card->getCurrStar()>=1)
                {
                    
                    CCArray* array =SGPlayerInfo::sharePlayerInfo()->getOfficerCards();
                    for(int i=0;i<array->count();i++)
                    {
                        SGBaseMilitaryCard *baseMilitaryCard = (SGBaseMilitaryCard *)array->objectAtIndex(i);
                        SGOfficerCard *card1 = (SGOfficerCard *)baseMilitaryCard;
                        int po1 = SGTeamgroup::shareTeamgroupInfo()->getPositionId(1,card1);
                        int po2 = SGTeamgroup::shareTeamgroupInfo()->getPositionId(2,card1);
                        int po3 = SGTeamgroup::shareTeamgroupInfo()->getPositionId(3,card1);
                        if ( po1 == 0 && po2 ==0 && po3 == 0 && card1->getIsProt() == 0 && card1->getSsid()!=card->getSsid() && card1->getProtoId() ==((SGOfficerCard*)card)->getProtoId() && card->getCurrStar() == card1->getCurrStar())
                        {
                            usednum++;
                        }
                    }
                    
                    
                }
                else
                {
                    int star = card->getCurrStar()-1;
                    bool po = !(SGTeamgroup::shareTeamgroupInfo()->isOnEmbattle((SGOfficerCard*)card));
                    usednum = stars[star]-(int)po;
                    
                }

                card->setAdvanceStuffNum(usednum);
                _allData->addObject(card);
            }
                                   
        
        }
//.........这里部分代码省略.........
开发者ID:caoguoping,项目名称:warCraft,代码行数:101,代码来源:SGGeneralsLayer.cpp

示例7: onMenu


//.........这里部分代码省略.........
            selectLayer->setTag(kRPGBattleSceneLayerTagItemsSelectDialog);
            
            ((RPGBattleSceneLayer*)this->m_parentNode)->addChild(selectLayer);
            ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(true);
            
            //显示title和分隔线
            addLab(selectLayer, 199, (CCString*)this->m_stringList->objectForKey("items_title"), 25, ccp(310, 285));
            CCLabelTTF *titleLab = (CCLabelTTF*)selectLayer->getChildByTag(199);
            titleLab->setFontFillColor(ccc3(144, 144, 144));
            
            CCSprite *separate = CCSprite::createWithSpriteFrameName("separate.png");
            separate->setPosition(ccp(selectLayer->getContentSize().width / 2, 260));
            separate->setScaleX(0.65);
            separate->setTag(198);
            selectLayer->addChild(separate);
            
            //加载道具数据
            CCTableView *tableView = (CCTableView*)selectLayer->getChildByTag(197);
            if(!tableView)
            {
                tableView = CCTableView::create(this, ccp(selectLayer->getContentSize().width, selectLayer->getContentSize().height - 80));
                tableView->setDirection(kCCScrollViewDirectionVertical);
                tableView->setPosition(CCSizeZero);
                tableView->setDelegate(this);
                tableView->setVerticalFillOrder(kCCTableViewFillTopDown);
                tableView->setTag(197);
                selectLayer->addChild(tableView);
            }
            
            this->m_tableItems->removeAllObjects();
            
            CCArray *existingItems = ((RPGBattleSceneLayer*)this->m_parentNode)->m_existingItems;
            
            for (int i = 0; i < existingItems->count(); i++)
                this->m_tableItems->addObject(existingItems->objectAtIndex(i));
            
            tableView->reloadData();
            //加载道具数据 end
            
            ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(false);
        }
            break;
        case kRPGBattleMenuTagEscape:
        {
//            CCLog("逃跑");
            
            float success = CCRANDOM_0_1();
            if(success >= 0.0 && success <= 0.5)
            {
//                CCLog("逃跑成功");
                
                this->setEnabled(false);
                this->removeFromParentAndCleanup(true);
                
                ((RPGBattleSceneLayer*)this->m_parentNode)->goToMap();
            }
            else
            {
                ((RPGBattleSceneLayer*)this->m_parentNode)->showMsg((CCString*)this->m_stringList->objectForKey("escape_fail"));
                
                //重置进度条
                this->m_playerData->m_progress = 0.0;
                CCProgressTimer *battleProgress = (CCProgressTimer*)this->m_parentNode->getChildByTag(kRPGBattleSceneLayerTagPlayerProgress + this->m_playerData->m_dataId);
                battleProgress->setPercentage(this->m_playerData->m_progress);
                
                ((RPGBattleSceneLayer*)this->m_parentNode)->scheduleUpdate();
开发者ID:ChinaiOS,项目名称:OzgGameRPG,代码行数:67,代码来源:RPGBattleMenu.cpp

示例8: searchPath

MapNode* MapUtils::searchPath(int startRowIndex, int startColIndex, int endRowIndex, int endColIndex, Map* map)
{
	CCArray* openList = new CCArray;
	CCArray* closeList = new CCArray;
	MapNode* endNode = map->getMapNode(endRowIndex, endColIndex);
	MapNode* searchNode = map->getMapNode(startRowIndex, startColIndex);
	searchNode->g = 0;
	searchNode->h = MapUtils::calculateH(searchNode, endNode);
	searchNode->f = searchNode->g + searchNode->h;
	int g, f, h;
	const int NORMAL = 10;
	const int ANGLE = 14;
	while (searchNode->nodeData->matrixIndex->rowIndex != endRowIndex || searchNode->nodeData->matrixIndex->colIndex != endColIndex)
	{
		/***遍历点的四周****/
		int colIndex, rowIndex, col, row, i, j;
		row = std::min(searchNode->nodeData->matrixIndex->rowIndex + 2, map->nodeData->matrix->row);
		col = std::min(searchNode->nodeData->matrixIndex->colIndex + 2, map->nodeData->matrix->col);
		rowIndex = std::max(searchNode->nodeData->matrixIndex->rowIndex - 1, 0);
		colIndex = std::max(searchNode->nodeData->matrixIndex->colIndex - 1, 0);
		for (i = rowIndex; i < row; i ++)
		{

			for (j = colIndex; j < col; j ++)
			{
				MapNode* checkNode = map->getMapNode(i, j);
				/**是否和检测的节点相等**/
				bool b1 = MapUtils::checkNode(searchNode, checkNode);
				/**是否容许通过**/
				bool b2 = MapUtils::checkAllow(checkNode);
				/**斜角是否容许通过**/
				bool b3 = MapUtils::checkAllow(map->getMapNode(searchNode->nodeData->matrixIndex->rowIndex, checkNode->nodeData->matrixIndex->colIndex));
				/**斜角是否容许通过**/
				bool b4 = MapUtils::checkAllow(map->getMapNode(searchNode->nodeData->matrixIndex->colIndex, checkNode->nodeData->matrixIndex->rowIndex));
				if (b1 == true || b2 == false || b3 == false || b4 == false)
				{
					continue;
				}
				if (searchNode->nodeData->matrixIndex->rowIndex != checkNode->nodeData->matrixIndex->rowIndex
					&& searchNode->nodeData->matrixIndex->colIndex != checkNode->nodeData->matrixIndex->colIndex)
				{
					g = searchNode->g + ANGLE;
				}
				else
				{
					g = searchNode->g + NORMAL;
				}
				h = MapUtils::calculateH(checkNode, endNode);
				f = g + h;
				if (checkNode->isOpen == true || checkNode->isClose == true)
				{
					if (checkNode->f > f)
					{
						checkNode->f = f;
						checkNode->h = h;
						checkNode->g = g;
						checkNode->father = searchNode;
					}
				}
				else
				{
					checkNode->f = f;
					checkNode->h = h;
					checkNode->g = g;
					checkNode->father = searchNode;

					checkNode->isOpen = true;
					openList->addObject(checkNode);
				}
			}
		}
		searchNode->isClose = true;
		closeList->addObject(searchNode);
		if (openList->count() <= 0)
		{
			return NULL;
		}
		searchNode = MapUtils::getMinF(openList);/**获取f值最小的节点,并且从openList中删除**/
		searchNode->isOpen = false;
	}
	clearCloseList(closeList);
	clearOpenList(openList);
	delete openList;
	delete closeList;
	return searchNode;
}
开发者ID:spzktshow,项目名称:isoMap,代码行数:86,代码来源:MapData.cpp

示例9: executeNodeTouchesEvent

int CCLuaEngine::executeNodeTouchesEvent(CCNode* pNode, int eventType, CCSet *pTouches, int phase)
{
    m_stack->clean();
    CCLuaValueDict event;
    switch (eventType)
    {
    case CCTOUCHBEGAN:
        event["name"] = CCLuaValue::stringValue("began");
        break;

    case CCTOUCHMOVED:
        event["name"] = CCLuaValue::stringValue("moved");
        break;

    case CCTOUCHENDED:
        event["name"] = CCLuaValue::stringValue("ended");
        break;

    case CCTOUCHCANCELLED:
        event["name"] = CCLuaValue::stringValue("cancelled");
        break;

    case CCTOUCHADDED:
        event["name"] = CCLuaValue::stringValue("added");
        break;

    case CCTOUCHREMOVED:
        event["name"] = CCLuaValue::stringValue("removed");
        break;

    default:
        return 0;
    }

    event["mode"] = CCLuaValue::intValue(kCCTouchesAllAtOnce);
    switch (phase)
    {
    case NODE_TOUCH_CAPTURING_PHASE:
        event["phase"] = CCLuaValue::stringValue("capturing");
        break;

    case NODE_TOUCH_TARGETING_PHASE:
        event["phase"] = CCLuaValue::stringValue("targeting");
        break;

    default:
        event["phase"] = CCLuaValue::stringValue("unknown");
    }

    CCLuaValueDict points;
    CCDirector* pDirector = CCDirector::sharedDirector();
    char touchId[16];
    for (CCSetIterator touchIt = pTouches->begin(); touchIt != pTouches->end(); ++touchIt)
    {
        CCLuaValueDict point;
        CCTouch* pTouch = (CCTouch*)*touchIt;
        sprintf(touchId, "%d", pTouch->getID());
        point["id"] = CCLuaValue::stringValue(touchId);

        const CCPoint pt = pDirector->convertToGL(pTouch->getLocationInView());
        point["x"] = CCLuaValue::floatValue(pt.x);
        point["y"] = CCLuaValue::floatValue(pt.y);
        const CCPoint prev = pDirector->convertToGL(pTouch->getPreviousLocationInView());
        point["prevX"] = CCLuaValue::floatValue(prev.x);
        point["prevY"] = CCLuaValue::floatValue(prev.y);

        points[touchId] = CCLuaValue::dictValue(point);
    }
    event["points"] = CCLuaValue::dictValue(points);
    m_stack->pushCCLuaValueDict(event);

    int eventInt = (phase == NODE_TOUCH_CAPTURING_PHASE) ? NODE_TOUCH_CAPTURE_EVENT : NODE_TOUCH_EVENT;
    CCArray *listeners = pNode->getAllScriptEventListeners();
    CCScriptHandlePair *p;
    for (int i = listeners->count() - 1; i >= 0; --i)
    {
        p = dynamic_cast<CCScriptHandlePair*>(listeners->objectAtIndex(i));
        if (p->event != eventInt || p->removed) continue;
        m_stack->copyValue(1);
        m_stack->executeFunctionByHandler(p->listener, 1);
        m_stack->settop(1);
    }

    m_stack->clean();

    return 1;
}
开发者ID:yinjimmy,项目名称:mini-q,代码行数:87,代码来源:CCLuaEngine.cpp

示例10: update

void FirstLevel::update(float dt) {
/*parallax */
	CCPoint backgroundScrollVert = ccp(-1000,0) ;
	_background->setPosition(ccpAdd(_background->getPosition(),ccpMult(backgroundScrollVert,dt)));

	CCArray *spaceDusts = CCArray::createWithCapacity(2);
	spaceDusts->addObject(_spacedust1) ;
	spaceDusts->addObject(_spacedust2) ;
	for (int i = 0; i < spaceDusts->count(); i++ ) {
		CCSprite * spaceDust = (CCSprite *)(spaceDusts->objectAtIndex(i)) ;
		float xPosition = _background->convertToWorldSpace(spaceDust->getPosition()).x;
		float size = spaceDust->getContentSize().width ;
		if (xPosition < -size)
			_background->incrementOffset(ccp(spaceDust->getContentSize().width*2,0),spaceDust);
	}
/*end parallax */
/*accelerometer*/
	float maxY = winSize.height - _ship->getContentSize().height/2;
	float minY = _ship->getContentSize().height/2;
	float diff = _shipPositionY * dt;
	float newY = _ship->getPosition().y + diff;

	newY = MIN(MAX(newY, minY), maxY);
	_ship->setPosition(ccp(_ship->getPosition().x, newY));
/*end accelerometer*/

/*first we move sprites and then bodies*/
/*sprites animation*/
	float curTime = getTimeTick();

	if (curTime > _nextAsteroidSpawn){                   // if time to show new asteroid?
		float randY  = randomBetween(0, winSize.height); // new asteroid position
		float randms = randomBetween(0.2, 1.0)*1000;     // how often show new asteroid

		_nextAsteroidSpawn = randms + curTime;		     // when show next asteroid
		float duration = randomBetween(1.0, 7.0);		 // android's "speed"

		Asteroid* asteroid = _asteroids->at(_nextAsteroid++);
		if(_nextAsteroid >= _asteroids->size())
			_nextAsteroid = 0;
		/*take asteroid from cage and set next params;
		 *when asteroid end moving - hide */
			asteroid->stopAllActions();
			asteroid->setPosition(ccp(winSize.width + asteroid->getContentSize().width/2, randY));
			asteroid->setLives(3);
			asteroid->setVisible(true);
			asteroid->runAction(CCSequence::create(CCMoveBy::create(duration,ccp( -winSize.width - asteroid->getContentSize().width, 0)),
								 	 	           CCCallFuncN::create(this, callfuncN_selector(FirstLevel::setInvisible)),NULL));
	}
/*end sprites animation*/

/*bodies animation*/
	_world->Step(dt, 10, 10);
	for(b2Body *b = _world->GetBodyList(); b; b = b->GetNext()){
		if (b->GetUserData() != NULL){
			CCSprite* sprite = (CCSprite*) b->GetUserData();
			if (sprite->isVisible()) {
				b2Vec2 position = b2Vec2(sprite->getPosition().x/PTM_RATIO,
									sprite->getPosition().y/PTM_RATIO);
				float angle = -1 * CC_DEGREES_TO_RADIANS(sprite->getRotation());
				b->SetTransform(position, angle);
			}
		}
	}
/*end bodies animation*/

/*body's collisions*/
	std::deque<CurrentContact>::iterator i;
	for(i = _collisionListener->contacts.begin(); i != _collisionListener->contacts.end(); ++i){
		CurrentContact contact = *i;
		b2Body *a = contact.a->GetBody();
		b2Body *b = contact.b->GetBody();

		if (a->GetUserData() != NULL && b->GetUserData() != NULL){
			CCSprite *sA = (CCSprite*)a->GetUserData();
			CCSprite *sB = (CCSprite*)b->GetUserData();

			Asteroid *ast;
			CCSprite *bullet;
			if (sA->isVisible() && sB->isVisible()) {
/*asteroid and bullet (laser)*/
				//if (sA->getTag() != 0 || sB->getTag() != 0)
				if ((sA->getTag() == 1 && sB->getTag() == 2) ||
					(sA->getTag() == 2 && sB->getTag() == 1)) {
					b2Body *temp; // bullet body
					if (sA->getTag() == 1) {
						ast    = (Asteroid*) a->GetUserData();
						bullet = (CCSprite*) b->GetUserData();
						temp   = b;
					} else {
						ast    = (Asteroid*) b->GetUserData();
						bullet = (CCSprite*) a->GetUserData();
						temp   = a;
					}
					if (ast->getLives() > 1){  // hide only bullet
						ast->subLife();
						temp->SetTransform(b2Vec2(-100.0, -100.0), 0.0f); // bullet body
					} else { // hide asteroid and bullet
						a->SetTransform(b2Vec2(-100.0, -100.0), 0.0f);
						b->SetTransform(b2Vec2(-100.0, -100.0), 0.0f);
//.........这里部分代码省略.........
开发者ID:BellyWong,项目名称:Space,代码行数:101,代码来源:FirstLevel.cpp

示例11: executeNodeTouchEvent

int CCLuaEngine::executeNodeTouchEvent(CCNode* pNode, int eventType, CCTouch *pTouch, int phase)
{
    m_stack->clean();
    CCLuaValueDict event;
    switch (eventType)
    {
    case CCTOUCHBEGAN:
        event["name"] = CCLuaValue::stringValue("began");
        break;

    case CCTOUCHMOVED:
        event["name"] = CCLuaValue::stringValue("moved");
        break;

    case CCTOUCHENDED:
        event["name"] = CCLuaValue::stringValue("ended");
        break;

    case CCTOUCHCANCELLED:
        event["name"] = CCLuaValue::stringValue("cancelled");
        break;

    default:
        CCAssert(false, "INVALID touch event");
        return 0;
    }

    event["mode"] = CCLuaValue::intValue(kCCTouchesOneByOne);
    switch (phase)
    {
    case NODE_TOUCH_CAPTURING_PHASE:
        event["phase"] = CCLuaValue::stringValue("capturing");
        break;

    case NODE_TOUCH_TARGETING_PHASE:
        event["phase"] = CCLuaValue::stringValue("targeting");
        break;

    default:
        event["phase"] = CCLuaValue::stringValue("unknown");
    }

    const CCPoint pt = CCDirector::sharedDirector()->convertToGL(pTouch->getLocationInView());
    event["x"] = CCLuaValue::floatValue(pt.x);
    event["y"] = CCLuaValue::floatValue(pt.y);
    const CCPoint prev = CCDirector::sharedDirector()->convertToGL(pTouch->getPreviousLocationInView());
    event["prevX"] = CCLuaValue::floatValue(prev.x);
    event["prevY"] = CCLuaValue::floatValue(prev.y);

    m_stack->pushCCLuaValueDict(event);

    int eventInt = (phase == NODE_TOUCH_CAPTURING_PHASE) ? NODE_TOUCH_CAPTURE_EVENT : NODE_TOUCH_EVENT;
    CCArray *listeners = pNode->getAllScriptEventListeners();
    CCScriptHandlePair *p;
    int ret = 1;
    for (int i = listeners->count() - 1; i >= 0; --i)
    {
        p = dynamic_cast<CCScriptHandlePair*>(listeners->objectAtIndex(i));
        if (p->event != eventInt || p->removed) continue;

        if (eventType == CCTOUCHBEGAN)
        {
            // enable listener when touch began
            p->enabled = true;
        }

        if (p->enabled)
        {
            m_stack->copyValue(1);
            int listenerRet = m_stack->executeFunctionByHandler(p->listener, 1);
            if (listenerRet == 0)
            {
                if (phase == NODE_TOUCH_CAPTURING_PHASE && (eventType == CCTOUCHBEGAN || eventType == CCTOUCHMOVED))
                {
                    ret = 0;
                }
                else if (phase == NODE_TOUCH_TARGETING_PHASE && eventType == CCTOUCHBEGAN)
                {
                    // if listener return false when touch began, disable this listener
                    p->enabled = false;
                    ret = 0;
                }
            }
            m_stack->settop(1);
        }
    }

    //CCLOG("executeNodeTouchEvent %p, ret = %d, event = %d, phase = %d", pNode, ret, eventType, phase);
    m_stack->clean();

    return ret;
}
开发者ID:yinjimmy,项目名称:mini-q,代码行数:92,代码来源:CCLuaEngine.cpp

示例12: showCream

void SGLootWiKiLayer::showCream(CCObject * sender)
{
    SGSocketRequest *req = (SGSocketRequest *)sender;
    main::BossPlotListResponse *response = (main::BossPlotListResponse *)req->m_msg;
    CCArray * array = SGPlayerInfo::sharePlayerInfo()->getStoryData();
    if (response)
    {
        int index = array->count() - (m_plotId - 20000);
        if (index >= 0 && index < array->count())
        {
            SGStoryBean *story = (SGStoryBean *)array->objectAtIndex( index ); //精英关卡的排序是反向的!最初的关卡索引反而大!
            int size = response->bossplotmodel_size();
            if (size > 0)
            {
                for (int ii = 0; ii < size; ii++)
                {
                    main::BossPlotModel model = response->bossplotmodel(ii);
                    CCLOG("scene ID=================%d", model.plotid());
                    SGStorySceneBean *scene = story->getSceneBeanById(model.plotid());
                    if (scene == NULL)
                    {
                        continue;
                    }
                    else
                    {
                        scene->setVisible(true);
                        //scene->setRank(model.ra);
                        scene->setPower(model.power());
                        scene->setGold(model.gold());
                        scene->setExp(model.exp());
                        scene->setZhandou(model.zhandou());
                        scene->setRank(model.rank());
                        scene->setCreamCanJoin(model.canjoin());
                        
                        //数据存储在playerinfo中
                        SGPlayerInfo::sharePlayerInfo()->setCreamData(model.plotid(), model.canjoincount(), model.canjoin());
                        
                        
                        scene->setCreamDayTimes(model.canjoincount());
                        scene->setCreamBuyTimes(model.canbuycount());
                        scene->setBuyPrice(model.price());
                        scene->setBuyCompTimes(model.buycount());// 已经购买次数
                        scene->setDropInfo(model.exp(), model.gold());
                        
                        //精英闯关 剩余次数存储在playerinfo中
                        //SGPlayerInfo::sharePlayerInfo()->setLeftCreamTimes(model.canjoincount());
                        
                        int itemNum = model.itemids_size();
                        scene->itemIds.clear();
                        for (int jj =0;jj<itemNum; jj++) {
                            scene->itemIds.push_back(model.itemids(jj));
                        }
                        
                    }
                    SGPlayerInfo::sharePlayerInfo()->setMaxBossPlotId(model.plotid());
                }
            }
            //假如可能出现问题,也能跳关,只是关卡会显示不正确。
            SGMainManager::shareMain()->showStorySectionLayer(story);
        }
        
        //不判断该关卡是否能打,交给精英节列表的逻辑。
//        if(!SGPlayerInfo::sharePlayerInfo()->getCreamIsCanJoin(SGMainManager::static_plotId))
//        {
//            int leftJoinCount = SGStaticDataManager::shareStatic()->getCreamByPlotId(SGMainManager::static_plotId)->getCreamDayTimes() - SGPlayerInfo::sharePlayerInfo()->getCreamJoinedCount(SGMainManager::static_plotId) ;
//            SGMainManager::shareMain()->showMessage(str_lootWiKi_10);
//            SGMainManager::sourceToStory = false;
//        }
//        else
        {
            SGMainManager::shareMain()->m_trackIsPve = false;
            m_lootWikiMainLayer->boxClose();
        }
    }
    SGMainManager::sourceToStory = false;
}
开发者ID:caoguoping,项目名称:warCraft,代码行数:76,代码来源:SGLootWiKiLayer.cpp

示例13: setRequestDialogParamsJni

	void setRequestDialogParamsJni(jobject obj, CCDictionary *params){
		JniMethodInfo t;
		if(params == NULL){
			return;
		}
		if(JniHelper::getMethodInfo(t, "java/util/TreeMap", "<init>", "()V")){
			jobject map = t.env->NewObject(t.classID, t.methodID);
			if(map == NULL){
				CCLog("Cannot create new TreeMap objeect in %S", __func__);
				return;
			}
			JniMethodInfo m;
			if(GreeJniHelper::getInstanceMethodInfo(m, map, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;")){
				CCDictElement* pElement = NULL;
				CCDICT_FOREACH(params, pElement){
					const std::string str = pElement->getStrKey();
					const char *pStr = str.c_str();
					jstring jStr;
					if(!pStr){
						jStr = t.env->NewStringUTF("");
					}else{
						jStr = t.env->NewStringUTF(pStr);
					}
					if(!strncmp(GD_REQUEST_DIALOG_PARAM_KEY_TITLE, pStr, sizeof(GD_REQUEST_DIALOG_PARAM_KEY_TITLE)) || 
						!strncmp(GD_REQUEST_DIALOG_PARAM_KEY_BODY, pStr, sizeof(GD_REQUEST_DIALOG_PARAM_KEY_BODY)) ||
						!strncmp(GD_REQUEST_DIALOG_PARAM_KEY_LISTTYPE, pStr, sizeof(GD_REQUEST_DIALOG_PARAM_KEY_LISTTYPE)) ||
						!strncmp(GD_REQUEST_DIALOG_PARAM_KEY_EXPIRETIME, pStr, sizeof(GD_REQUEST_DIALOG_PARAM_KEY_EXPIRETIME))){
						// title, body, list_type, expire_time
						CCString *val = ((CCString *)(pElement->getObject()));
						if(val == NULL){
							return;
						}
						const char *pVal  = val->getCString();
						jstring jVal;
						if(!pVal){
							jVal = t.env->NewStringUTF("");
						}else{
							jVal = t.env->NewStringUTF(pVal);
						}
						m.env->CallObjectMethod(map, m.methodID, jStr, jVal);
						m.env->DeleteLocalRef(jVal);
					}else if(!strncmp(GD_REQUEST_DIALOG_PARAM_KEY_TOUSERID, pStr, sizeof(GD_REQUEST_DIALOG_PARAM_KEY_TOUSERID))){
						//touserid
						CCArray *array = ((CCArray *)(pElement->getObject()));
						if(array == NULL){
							return;
						}
						jclass jcl = JniHelper::getClassID("java/lang/String");
						if(jcl == NULL){
							return;
						}
						jobjectArray jarry = t.env->NewObjectArray(array->count(), jcl, NULL);
						CCObject *it;
						int i = 0;
						CCARRAY_FOREACH(array, it){
							CCString *val = dynamic_cast<CCString *>(it);
							const char *pVal = val->getCString();
							jstring jVal;
							if(!pVal){
								jVal = t.env->NewStringUTF("");
							}else{
								jVal = t.env->NewStringUTF(pVal);
							}
							t.env->SetObjectArrayElement(jarry, i, jVal);
							t.env->DeleteLocalRef(jVal);
							i++;
						}
						m.env->CallObjectMethod(map, m.methodID, jStr, jarry);
						t.env->DeleteLocalRef(jarry);
					}else if(!strncmp(GD_REQUEST_DIALOG_PARAM_KEY_ATTRS, pStr, sizeof(GD_REQUEST_DIALOG_PARAM_KEY_ATTRS))){
开发者ID:TsaoChiyen,项目名称:GreePlatformSDKCocos2dx,代码行数:70,代码来源:Java_org_cocos2dx_lib_Cocos2dxGreeRequestDialog.cpp

示例14: writeHeaderData

 /// Callback function used by libcurl for collect header data
 static size_t writeHeaderData(void* ptr, size_t size, size_t nmemb, void* userdata) {
     CURLHandler* handler = (CURLHandler*)userdata;
     size_t sizes = size * nmemb;
     
     // lock
     pthread_mutex_lock(&handler->m_mutex);
     
     // parse pair
     string header((const char*)ptr, sizes);
     CCArray* pair = new CCArray();
     if(!header.empty()) {
         // remove head and tailing brace, bracket, parentheses
         size_t start = 0;
         size_t end = header.length() - 1;
         char c = header[start];
         while(c == '{' || c == '[' || c == '(') {
             start++;
             c = header[start];
         }
         c = header[end];
         while(c == '}' || c == ']' || c == ')') {
             end--;
             c = header[end];
         }
         
         // iterate string
         size_t compStart = start;
         for(size_t i = start; i <= end; i++) {
             c = header[i];
             if(c == ':') {
                 CCString* s = new CCString(header.substr(compStart, i - compStart));
                 pair->addObject(s);
                 s->release();
                 compStart = i + 1;
             } else if(c == ' ' || c == '\t' || c == '\r' || c == '\n') {
                 if(compStart == i) {
                     compStart++;
                 }
             }
         }
         
         // last comp
         // or, if last char is separator, append an empty string
         if(compStart <= end) {
             CCString* s = new CCString(header.substr(compStart, end - compStart + 1));
             pair->addObject(s);
             s->release();
         } else if(header[end] == ':') {
             CCString* s = new CCString("");
             pair->addObject(s);
             s->release();
         }
     }
     
     // if pair count is two, means ok
     if(pair->count() == 2) {
         handler->m_ctx->response->addHeader(((CCString*)pair->objectAtIndex(0))->getCString(),
                                             ((CCString*)pair->objectAtIndex(1))->getCString());
     }
     
     // release array
     pair->release();
     
     // unlock
     pthread_mutex_unlock(&handler->m_mutex);
     
     // return a value which is different with sizes will abort it
     if(handler->m_ctx->request->isCancel())
         return sizes + 1;
     else
         return sizes;
 }
开发者ID:Ratel13,项目名称:cocos2dx-better,代码行数:73,代码来源:CBHttpClient.cpp

示例15: createMenuItems

void BuildScroll::createMenuItems()
{
    // set common variables
    CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
    
    // create the build group background
    string buildBackground = "scrollermiddle_b.png";
    buildMenu = CCSprite::createWithSpriteFrameName(buildBackground.c_str());
    CCSize spriteSize = buildMenu->getContentSize();
    buildMenu->setAnchorPoint(ccp(0, 0));
    buildMenu->setScale(screenSize.width / spriteSize.width * 0.98f);
    buildMenu->setPosition(ccp(screenSize.width * (1.01f - leftPos), 25));
    this->addChild(buildMenu, 1);
    
    scrollerBar = CCSprite::createWithSpriteFrameName("scroller_side.png");
    scrollerBar->setAnchorPoint(ccp(0, 0));
    scrollerBar->setScale(screenSize.width / spriteSize.width * 0.98f);
    scrollerBar->setPosition(ccp(screenSize.width * (1.0f - leftPos), 0));
    this->addChild(scrollerBar, 2);
    
    // scroll section for other villagers
    scrollArea = new ScrollArea();
    scrollArea->createScrollArea(CCSizeMake(buildMenu->boundingBox().size.width * 0.96f, buildMenu->boundingBox().size.height * 0.92f), CCSizeMake(BuildingHandler::getThis()->allBuildings->count() , buildMenu->boundingBox().size.height * 0.92f));
    scrollArea->enableScrollHorizontal(0, "bar.png", "bar.png");
    scrollArea->setAnchorPoint(ccp(0, 0));
    
    // create all building references for all building categories.
    CCArray* allBuildings = BuildingHandler::getThis()->allBuildings;
    // list down all the buildings
    
    numberOfBuildingCards = 0;
    BuildingCard* bc = BuildingCard::create(NULL, scrollArea, numberOfBuildingCards, 1);
    numberOfBuildingCards++;
    buildingCards->addObject(bc);
    
    bc = BuildingCard::create(NULL, scrollArea, numberOfBuildingCards, 2);
    numberOfBuildingCards++;
    buildingCards->addObject(bc);
    
    bc = BuildingCard::create(NULL, scrollArea, numberOfBuildingCards, 3);
    numberOfBuildingCards++;
    buildingCards->addObject(bc);
    
    for(int i = 0; i < allBuildings->count(); i++)
    {
        Building* tempBuilding = (Building*) allBuildings->objectAtIndex(i);
        if(tempBuilding->buildingType == HOUSING)
        {
            if (!nameExists(tempBuilding->buildingName))
            {
                bc = BuildingCard::create(tempBuilding, scrollArea, numberOfBuildingCards, 0);
                numberOfBuildingCards++;
                buildingCards->addObject(bc);
            }
        }
    }
    
    for(int i = 0; i < allBuildings->count(); i++)
    {
        Building* tempBuilding = (Building*) allBuildings->objectAtIndex(i);
        if(tempBuilding->buildingType == AMENITY)
        {
            // if (!nameExists(tempBuilding->buildingName))
            // {
            
            
            bc = BuildingCard::create(tempBuilding, scrollArea, numberOfBuildingCards, 0);
            numberOfBuildingCards++;
            buildingCards->addObject(bc);
            // }
        }
    }
    
    for(int i = 0; i < allBuildings->count(); i++)
    {
        Building* tempBuilding = (Building*) allBuildings->objectAtIndex(i);
        if(tempBuilding->buildingType == GRANARY)
        {
            bc = BuildingCard::create(tempBuilding, scrollArea, numberOfBuildingCards, 0);
            numberOfBuildingCards++;
            buildingCards->addObject(bc);
        }
    }
    
    for(int i = 0; i < allBuildings->count(); i++)
    {
        Building* tempBuilding = (Building*) allBuildings->objectAtIndex(i);
        if(tempBuilding->buildingType == MARKET)
        {
            bc = BuildingCard::create(tempBuilding, scrollArea, numberOfBuildingCards, 0);
            numberOfBuildingCards++;
            buildingCards->addObject(bc);
        }
    }
    
    for(int i = 0; i < allBuildings->count(); i++)
    {
        Building* tempBuilding = (Building*) allBuildings->objectAtIndex(i);
        if(tempBuilding->buildingType == MILITARY)
        {
//.........这里部分代码省略.........
开发者ID:larryPersonal,项目名称:Nanhua,代码行数:101,代码来源:BuildScroll.cpp


注:本文中的CCArray::count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。