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


C++ CCInteger类代码示例

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


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

示例1: update

void EntityManager::update(float dt) {
    CCArray *keys = m_pIDToEntitiesMap->allKeys();
    if (keys) {     // if the dictionary has no objects, keys will be NULL
        for (int i=0; i<keys->count(); i++) {
            CCInteger *integer = (CCInteger *)keys->objectAtIndex(i);
            int key = integer->getValue();
            
            BaseGameEntity *entity = (BaseGameEntity *)m_pIDToEntitiesMap->objectForKey(key);
            if (entity->getIsActive()) {    // Only update the entity if it's active.
                entity->update(dt);
            }
        }
    }
    
    /*
    // Add new entities.
    for (int i=0; i<m_pEntitiesToAdd->count(); i++) {
        BaseGameEntity *newEntity = (BaseGameEntity *)m_pEntitiesToAdd->objectAtIndex(i);
        m_pIDToEntitiesMap->setObject(newEntity, newEntity->getID());
    }
    m_pEntitiesToAdd->removeAllObjects();
    */
    
    // Remove old entities.
    for (int i=0; i<m_pEntitiesToRemove->count(); i++) {
        BaseGameEntity *oldEntity = (BaseGameEntity *)m_pEntitiesToRemove->objectAtIndex(i);
        m_pIDToEntitiesMap->removeObjectForKey(oldEntity->getID());
    }
    m_pEntitiesToRemove->removeAllObjects();
}
开发者ID:adahera222,项目名称:Samurai-TD,代码行数:30,代码来源:EntityManager.cpp

示例2: CCAssert

// CCTileMapAtlas - Atlas generation / updates
void CCTileMapAtlas::setTile(const ccColor3B& tile, const CCPoint& position)
{
    CCAssert(m_pTGAInfo != NULL, "tgaInfo must not be nil");
    CCAssert(m_pPosToAtlasIndex != NULL, "posToAtlasIndex must not be nil");
    CCAssert(position.x < m_pTGAInfo->width, "Invalid position.x");
    CCAssert(position.y < m_pTGAInfo->height, "Invalid position.x");
    CCAssert(tile.r != 0, "R component must be non 0");

    ccColor3B *ptr = (ccColor3B*)m_pTGAInfo->imageData;
    ccColor3B value = ptr[(unsigned int)(position.x + position.y * m_pTGAInfo->width)];
    if( value.r == 0 )
    {
        CCLOG("cocos2d: Value.r must be non 0.");
    } 
    else
    {
        ptr[(unsigned int)(position.x + position.y * m_pTGAInfo->width)] = tile;

        // XXX: this method consumes a lot of memory
        // XXX: a tree of something like that shall be implemented
        CCInteger *num = (CCInteger*)m_pPosToAtlasIndex->objectForKey(CCString::createWithFormat("%ld,%ld", 
                                                                                                 (long)position.x, 
                                                                                                 (long)position.y)->getCString());
        this->updateAtlasValueAt(position, tile, num->getValue());
    }    
}
开发者ID:06linux,项目名称:Cocos2d-x-ParticleEditor-for-Windows,代码行数:27,代码来源:CCTileMapAtlas.cpp

示例3: shadow

void ShadowingMan::shadow(CCObject* heroPos)
{
	CCArray* coords = (CCArray*)heroPos;
	CCInteger* intgx = (CCInteger*)coords->objectAtIndex(0);
	CCInteger* intgy = (CCInteger*)coords->objectAtIndex(1);
	CCPoint pos = ccp(intgx->getValue(),intgy->getValue());
	pos = pos - ccp(0, 2);
		
	Map* map = (Map*)rGlobal->map;
	CCPoint myPos = this->getPosition();
	CCPoint inTile = map->tileCoordFromPosition(myPos);
	CCPoint vect= ccp((pos.x-inTile.x), -(pos.y-inTile.y))*32;

	int dir=Down;
	if(vect.y==0)
	{
		if(vect.x>0) dir=Right;
		else if(vect.x<0) dir=Left;
		else return; //Hero moves not
	}
	else if(vect.x==0)
	{
		if(vect.y>0) dir=Up;
		else dir=Down;
	}
	else
		CCLog("Strange vect: (%f,%f)", vect.x, vect.y);

	const float duration=STD_WALK_DURATION/sGlobal->superPower->speed;
	CCMoveBy* move=CCMoveBy::create(duration*0.9,vect);
	CCAnimate* anim=CCAnimate::create(walkAnimations[dir]);//行走
	sprite->runAction(anim); this->runAction(move);
}
开发者ID:davidxk,项目名称:Blow-My-Lake,代码行数:33,代码来源:ShadowingMan.cpp

示例4: onCellClick

bool BBBuildingListManager::onCellClick(unsigned int nIndex, cocos2d::CCNode *pTarget, cocos2d::CCTouch *pTouch)
{
//	CCLOG("点击了第%d个建筑物", nIndex);
	
	
	BBUILayers::shared()->closeAllPopuper();
	
	//尝试建造一个新的建筑物
	CCInteger* buildingId = dynamic_cast<CCInteger*>(getObjectForIndex(nIndex));
	BBEntityModel* entityModel = BBComponentFactory::shared()->createEntityModel(buildingId->getValue(), 1);
	BBUnit* unit = BBUnit::create(entityModel);
    
	CCPoint tilePosition = BBGame::shared()->getCurrentMap()->getFreePosition(entityModel->m_sizePlaceSize);
	unit->setTilePosition(tilePosition);
	unit->setIsTempUnit(true);
	unit->setBuildingId(buildingId->getValue());
	BBGame::shared()->getCurrentMap()->attach(unit, true);		//添加单位,并选中
    
	int instanceId = GlobalData::getInstance()->generateInstanceId();

	unit->setInstanceId(instanceId);
    
//	CreateBuildingCommand* command = new CreateBuildingCommand(instanceId, buildingId->getValue(), tilePosition.x, tilePosition.y);
//    
//	command->send();
    
	
	return true;
};
开发者ID:newcl,项目名称:boom,代码行数:29,代码来源:BBBuildingListManager.cpp

示例5: getUnUsedIndex

void CCEGLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[],
										   float ys[])
{
	CCSet set;
	for (int i = 0; i < num; ++i)
	{
		int id = ids[i];
		float x = xs[i];
		float y = ys[i];

		CCInteger* pIndex = (CCInteger*) s_TouchesIntergerDict.objectForKey(id);
		int nUnusedIndex = 0;

		// it is a new touch
		if (pIndex == NULL)
		{
			nUnusedIndex = getUnUsedIndex();

			// The touches is more than MAX_TOUCHES ?
			if (nUnusedIndex == -1)
			{
				CCLOG("The touches is more than MAX_TOUCHES, nUnusedIndex = %d",
					nUnusedIndex);
				continue;
			}

			CCTouch* pTouch = s_pTouches[nUnusedIndex] = new CCTouch();
			if (m_bIsRetinaEnabled)
			{
				// on iOS, though retina is enabled, the value got from os is also 
				// relative to its original size
				pTouch->setTouchInfo(nUnusedIndex,
					(x - m_obViewPortRect.origin.x),
					(y - m_obViewPortRect.origin.y));
			}
			else
			{
				pTouch->setTouchInfo(nUnusedIndex,
					(x - m_obViewPortRect.origin.x) / m_fScaleX,
					(y - m_obViewPortRect.origin.y) / m_fScaleY);
			}

			//CCLOG("x = %f y = %f", pTouch->getLocationInView().x, pTouch->getLocationInView().y);

			CCInteger* pInterObj = new CCInteger(nUnusedIndex);
			s_TouchesIntergerDict.setObject(pInterObj, id);
			set.addObject(pTouch);
			pInterObj->release();
		}
	}

	if (set.count() == 0)
	{
		CCLOG("touchesBegan: count = 0");
		return;
	}

	m_pDelegate->touchesBegan(&set, NULL);
}
开发者ID:korman,项目名称:Temp,代码行数:59,代码来源:CCEGLViewProtocol.cpp

示例6: yesDialogBack

void LotteryRotateView::yesDialogBack(CCObject* pObj)
{
    CCInteger* money = dynamic_cast<CCInteger*>(pObj);
    if (money && GlobalData::shared()->playerInfo.gold < money->getValue())
    {
        YesNoDialog::gotoPayTips();
        return;
    }
//    playAnimation(1);
}
开发者ID:ourgames,项目名称:dc208,代码行数:10,代码来源:LotteryRotateView.cpp

示例7: multiShare

bool multiShare(CCArray *platTypes, CCDictionary *content, C2DXShareResultEvent callback) {
	int index = 0;
	int count = platTypes->count();
	while(index < count) {
		CCInteger* item = (CCInteger*) platTypes->objectAtIndex(index);
		int platformId = item->getValue();
		doShare(platformId, content, callback);
		index++;
	}
	return true;
}
开发者ID:00000110,项目名称:Four,代码行数:11,代码来源:ShareSDKUtils.cpp

示例8: ccarray_to_std_vector

NS_CC_BEGIN

static std::vector<unsigned int> ccarray_to_std_vector(CCArray* pArray)
{
    std::vector<unsigned int> ret;
    CCObject* pObj;
    CCARRAY_FOREACH(pArray, pObj)
    {
        CCInteger* pInteger = (CCInteger*)pObj;
        ret.push_back((unsigned int)pInteger->getValue());
    }
开发者ID:897290110,项目名称:MoonWarriors,代码行数:11,代码来源:CCMenu.cpp

示例9: ccarray_to_std_vector

NS_CC_BEGIN
    
static std::vector<KDuint> ccarray_to_std_vector ( CCArray* pArray )
{
    std::vector<KDuint>  aRet;
    
	CCObject*  pObject;
    CCARRAY_FOREACH ( pArray, pObject )
    {
        CCInteger*  pInteger = (CCInteger*) pObject;
        aRet.push_back ( (KDuint) pInteger->getValue ( ) );
    }
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:12,代码来源:CCMenu.cpp

示例10: handleTouchesMove

void CCEGLViewProtocol::handleTouchesMove(int num, int ids[], float xs[],
										  float ys[])
{
	CCSet set;
	for (int i = 0; i < num; ++i)
	{
		int id = ids[i];
		float x = xs[i];
		float y = ys[i];

		CCInteger* pIndex = (CCInteger*) s_TouchesIntergerDict.objectForKey(id);
		if (pIndex == NULL)
		{
			CCLOG("if the index doesn't exist, it is an error");
			continue;
		}

		CCLOGINFO("Moving touches with id: %d, x=%f, y=%f", id, x, y);
		CCTouch* pTouch = s_pTouches[pIndex->getValue()];
		if (pTouch)
		{
			if (m_bIsRetinaEnabled)
			{
				pTouch->setTouchInfo(pIndex->getValue(),
					(x - m_obViewPortRect.origin.x),
					(y - m_obViewPortRect.origin.y));
			}
			else
			{
				pTouch->setTouchInfo(pIndex->getValue(),
					(x - m_obViewPortRect.origin.x) / m_fScaleX,
					(y - m_obViewPortRect.origin.y) / m_fScaleY);
			}

			set.addObject(pTouch);
		}
		else
		{
			// It is error, should return.
			CCLOG("Moving touches with id: %d error", id);
			return;
		}
	}

	if (set.count() == 0)
	{
		CCLOG("touchesMoved: count = 0");
		return;
	}

	m_pDelegate->touchesMoved(&set, NULL);
}
开发者ID:korman,项目名称:Temp,代码行数:52,代码来源:CCEGLViewProtocol.cpp

示例11: executeEventWithArgs

int CCLuaEngine::executeEventWithArgs(int nHandler, CCArray* pArgs)
{
    if (NULL == pArgs)
        return 0;

    CCObject*   pObject = NULL;

    CCInteger*  pIntVal = NULL;
    CCString*   pStrVal = NULL;
    CCDouble*   pDoubleVal = NULL;
    CCFloat*    pFloatVal = NULL;
    CCBool*     pBoolVal = NULL;


    int nArgNums = 0;
    for (unsigned int i = 0; i < pArgs->count(); i++)
    {
        pObject = pArgs->objectAtIndex(i);
        if (NULL != (pIntVal = dynamic_cast<CCInteger*>(pObject)))
        {
            m_stack->pushInt(pIntVal->getValue());
            nArgNums++;
        }
        else if (NULL != (pStrVal = dynamic_cast<CCString*>(pObject)))
        {
            m_stack->pushString(pStrVal->getCString());
            nArgNums++;
        }
        else if (NULL != (pDoubleVal = dynamic_cast<CCDouble*>(pObject)))
        {
            m_stack->pushFloat(pDoubleVal->getValue());
            nArgNums++;
        }
        else if (NULL != (pFloatVal = dynamic_cast<CCFloat*>(pObject)))
        {
            m_stack->pushFloat(pFloatVal->getValue());
            nArgNums++;
        }
        else if (NULL != (pBoolVal = dynamic_cast<CCBool*>(pObject)))
        {
            m_stack->pushBoolean(pBoolVal->getValue());
            nArgNums++;
        }
        else if(NULL != pObject)
        {
            m_stack->pushCCObject(pObject, "CCObject");
            nArgNums++;
        }
    }

    return  m_stack->executeFunctionByHandler(nHandler, nArgNums);
}
开发者ID:fordream,项目名称:quick,代码行数:52,代码来源:CCLuaEngine.cpp

示例12: applyColorTransform

void CCINode::applyColorTransform(cocos2d::CCNode *node, ccColor4B colorTransform){
    CCArray * children =  node->getChildren();
    for (int i=0; i<node->getChildrenCount(); i++) {
        CCNode * childNode = (CCNode *)children->objectAtIndex(i);
        CCInteger * type = (CCInteger *)childNode->getUserObject();
        if (type->getValue()==NodeTypeSprite) {
            CCSprite * sprite = (CCSprite *)childNode;
            sprite->setColor(ccc3(colorTransform.r, colorTransform.g, colorTransform.b));
            sprite->setOpacity(colorTransform.a);
        }else{
            this->applyColorTransform(childNode, colorTransform);
        }
    }
}
开发者ID:Creativegame,项目名称:CocosInterpreter,代码行数:14,代码来源:CCINode.cpp

示例13: CCSoomlaError

    CCSoomlaError *CCSoomlaError::createWithObject(cocos2d::CCObject *obj) {
        CCDictionary *dict = dynamic_cast<CCDictionary *>(obj);
        if (dict != NULL && dict->objectForKey(JSON_ERROR_CODE) != NULL) {
            CCInteger *errorCode = dynamic_cast<CCInteger *>(dict->objectForKey(JSON_ERROR_CODE));
            CC_ASSERT(errorCode);

            CCSoomlaError *ret = new CCSoomlaError();
            ret->autorelease();
            ret->init(errorCode->getValue());
            return ret;
        } else {
            return NULL;
        }
    }
开发者ID:ciw604878870,项目名称:cocos2dx-store,代码行数:14,代码来源:CCSoomlaError.cpp

示例14: getUnUsedIndex

void CCEGLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[], float ys[])
{
    CCSet set;
    for (int i = 0; i < num; ++i)
    {
        int id = ids[i];
        float x = xs[i];
        float y = ys[i];

        CCInteger* pIndex = (CCInteger*)s_TouchesIntergerDict.objectForKey(id);
        int nUnusedIndex = 0;

        // it is a new touch
        if (pIndex == NULL)
        {
            nUnusedIndex = getUnUsedIndex();

            // The touches is more than MAX_TOUCHES ?
            if (nUnusedIndex == -1) {
                CCLOG("The touches is more than MAX_TOUCHES, nUnusedIndex = %d", nUnusedIndex);
                continue;
            }

            CCTouch* pTouch = s_pTouches[nUnusedIndex] = new CCTouch();
			pTouch->setTouchInfo(nUnusedIndex, (x - m_obViewPortRect.origin.x) / m_fScaleX, 
                                     (y - m_obViewPortRect.origin.y) / m_fScaleY);
            
            //CCLOG("x = %f y = %f", pTouch->getLocationInView().x, pTouch->getLocationInView().y);
            
            CCInteger* pInterObj = new CCInteger(nUnusedIndex);
            s_TouchesIntergerDict.setObject(pInterObj, id);
            set.addObject(pTouch);
            pInterObj->release();
        }
    }

    if (set.count() == 0)
    {
        CCLOG("touchesBegan: count = 0");
        return;
    }

    CCEvent event;
    CCSet *allTouches= new CCSet;
    allTouches->autorelease();
    getCurrentSetOfTouches(*allTouches);
    event.setAllTouches(allTouches);
    m_pDelegate->touchesBegan(&set, &event);
}
开发者ID:vedi,项目名称:cocos2d-x,代码行数:49,代码来源:CCEGLViewProtocol.cpp

示例15: json_object

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;
    }
	else if(dynamic_cast<CCInteger*>(obj)) 
	{
		CCInteger *mainInteger = (CCInteger*) obj;
		json_t* jsonString = json_integer(mainInteger->getValue());

		return jsonString;
	}
    
    return NULL;
}
开发者ID:AllenCoder,项目名称:EasyNDK-for-cocos2dx,代码行数:49,代码来源:NDKHelper.cpp


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