本文整理汇总了C++中CCInteger::getValue方法的典型用法代码示例。如果您正苦于以下问题:C++ CCInteger::getValue方法的具体用法?C++ CCInteger::getValue怎么用?C++ CCInteger::getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCInteger
的用法示例。
在下文中一共展示了CCInteger::getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSetOfTouchesEndOrCancel
void CCEGLViewProtocol::getSetOfTouchesEndOrCancel(CCSet& set, int num,
int ids[], float xs[], float ys[])
{
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;
}
/* Add to the set to send to the director */
CCTouch* pTouch = s_pTouches[pIndex->getValue()];
if (pTouch)
{
CCLOGINFO("Ending touches with id: %d, x=%f, y=%f", id, x, y);
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);
// release the object
pTouch->release();
s_pTouches[pIndex->getValue()] = NULL;
removeUsedIndexBit(pIndex->getValue());
s_TouchesIntergerDict.removeObjectForKey(id);
}
else
{
CCLOG("Ending touches with id: %d error", id);
return;
}
}
if (set.count() == 0)
{
CCLOG("touchesEnded or touchesCancel: count = 0");
return;
}
}
示例2: 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);
}
示例3: HandleTouchesEnd
void App::HandleTouchesEnd(int num, int ids[], float xs[], float ys[])
{
int i;
int id;
float x;
float y;
CCSet set;
CCTouch* pTouch;
CCInteger* pIndex;
for (i = 0; i < num; ++i)
{
id = ids[i];
x = xs[i];
y = ys[i];
pIndex = (CCInteger*)s_TouchesIntergerDict.objectForKey(id);
if (pIndex == NULL)
{
CCLOG("if the index doesn't exist, it is an error");
continue;
}
pTouch = s_pTouches[pIndex->getValue()];
if (pTouch)
{
CCLOGINFO("Ending touches with id: %d, x=%f, y=%f", id, x, y);
pTouch->setTouchInfo(pIndex->getValue(), x, y);
set.addObject(pTouch);
// release the object
pTouch->release();
s_pTouches[pIndex->getValue()] = NULL;
removeUsedIndexBit(pIndex->getValue());
s_TouchesIntergerDict.removeObjectForKey(id);
}
else
{
CCLOG("Ending touches with id: %d error", id);
return;
}
}
CCDirector::sharedDirector()->getTouchDispatcher()->touchesEnded(&set, NULL);
}
示例4: 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();
}
示例5: setTile
// 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());
}
}
示例6: HandleTouchesMove
void App::HandleTouchesMove(int num, int ids[], float xs[], float ys[])
{
int i;
int id;
float x;
float y;
CCSet set;
CCTouch* pTouch;
CCInteger* pIndex;
for (i = 0; i < num; ++i)
{
id = ids[i];
x = xs[i];
y = ys[i];
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);
pTouch = s_pTouches[pIndex->getValue()];
if (pTouch)
{
pTouch->setTouchInfo(pIndex->getValue(), x, y);
set.addObject(pTouch);
}
else
{
// It is error, should return.
CCLOG("Moving touches with id: %d error", id);
return;
}
}
if (set.count() > 0)
{
CCDirector::sharedDirector()->getTouchDispatcher()->touchesMoved(&set, NULL);
}
}
示例7: 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);
}
示例8: initWithDictionary
bool GAFInteractionObject::initWithDictionary(CCDictionary * aDictionary)
{
if (!aDictionary)
{
GAFLOGERROR("Error while creating GAFInteractionObject from NSDictionary. aDictionary must not be NULL.");
return false;
}
CCString * jName = (CCString*)aDictionary->objectForKey(kNameKey);
if (jName)
{
name = std::string(jName->getCString());
}
CCInteger * rectX = (CCInteger*)aDictionary->objectForKey(kRectXKey);
CCInteger * rectY = (CCInteger*)aDictionary->objectForKey(kRectYKey);
CCInteger * rectWidth = (CCInteger*)aDictionary->objectForKey(kRectWidthKey);
CCInteger * rectHeight = (CCInteger*)aDictionary->objectForKey(kRectHeightKey);
if (rectX && rectY && rectWidth && rectHeight)
{
bounds = GAFCCRectMake(rectX->getValue(), rectY->getValue(), rectWidth->getValue(), rectHeight->getValue());
}
else
{
GAFLOGERROR("Error while creating GAFInteractionObject from NSDictionary. One of rect* attributes missing.");
return false;
}
CCInteger * x = (CCInteger*)aDictionary->objectForKey(kXKey);
CCInteger * y = (CCInteger*)aDictionary->objectForKey(kYKey);
if (x && y)
{
pivotPoint = GAFCCPointMake(x->getValue(), y->getValue());
}
else
{
GAFLOGERROR("Error while creating GAFInteractionObject from NSDictionary. One of x, y attributes missing.");
return false;
}
return true;
}
示例9: 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;
}
示例10:
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());
}
示例11:
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 ( ) );
}
示例12: 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);
}
示例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;
}
}
示例14: 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);
}
}
}
示例15: GetJsonFromCCObject
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;
}