本文整理汇总了C++中CCArray::initWithCapacity方法的典型用法代码示例。如果您正苦于以下问题:C++ CCArray::initWithCapacity方法的具体用法?C++ CCArray::initWithCapacity怎么用?C++ CCArray::initWithCapacity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCArray
的用法示例。
在下文中一共展示了CCArray::initWithCapacity方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: executeTouchBeganHandler
CWidgetTouchModel CWidget::executeTouchBeganHandler(CCTouch* pTouch)
{
m_bTouchInterrupt = false;
if( m_pTouchBeganListener && m_pTouchBeganHandler )
{
CWidgetTouchModel eUserTouchModel = (m_pTouchBeganListener->*m_pTouchBeganHandler)(m_pThisObject, pTouch);
if( eUserTouchModel == eWidgetTouchNone )
{
return eWidgetTouchNone;
}
else
{
this->onTouchBegan(pTouch);
return eUserTouchModel;
}
}
#if USING_LUA
else if( m_nTouchBeganScriptHandler != 0 )
{
CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();
CCLuaStack* pStack = pEngine->getLuaStack();
pStack->pushCCObject(m_pThisObject, "CCObject");
pStack->pushCCObject(pTouch, "CCTouch");
CCArray* pRetArray = new CCArray();
pRetArray->initWithCapacity(1);
int nRet = pStack->executeFunctionReturnArray(m_nTouchBeganScriptHandler, 2, 1, pRetArray);
CCAssert(pRetArray->count() > 0, "return count = 0");
CCDouble* pIntModel = (CCDouble*) pRetArray->objectAtIndex(0);
CWidgetTouchModel eUserTouchModel = (CWidgetTouchModel) ( (int)pIntModel->getValue() );
delete pRetArray;
pStack->clean();
if( eUserTouchModel == eWidgetTouchNone )
{
return eWidgetTouchNone;
}
else
{
this->onTouchBegan(pTouch);
return eUserTouchModel;
}
}
#endif
return this->onTouchBegan(pTouch);
}
示例2: arrayWithCapacity
CCArray* CCArray::arrayWithCapacity(unsigned int capacity)
{
CCArray* pArray = new CCArray();
if (pArray && pArray->initWithCapacity(capacity))
{
pArray->autorelease();
}
else
{
CC_SAFE_DELETE(pArray);
}
return pArray;
}
示例3: if
CCObject * YHDataManagerImp::loadFile(const std::string & fullpath)
{
string suffix = pathExtensionWithString(fullpath);
asciiToLower(suffix);
// 装载对应的对象
CCObject * obj = NULL;
if (suffix.compare("plist-array") == 0)
{
ValueVector vv = CCFileUtils::getInstance()->getValueVectorFromFile(fullpath);
CCArray * arr = new CCArray();
arr->initWithCapacity((ssize_t)vv.size());
array_Value(arr, vv);
obj = arr;
}
else if (suffix.compare("plist-dictionary") == 0)
{
obj = CCDictionary::createWithContentsOfFileThreadSafe(fullpath.c_str());
}
else if (suffix.compare("png") == 0 || suffix.compare("jpg") == 0 || suffix.compare("jpeg") == 0
|| suffix.compare("tif") == 0 || suffix.compare("tiff") == 0 || suffix.compare("webp") == 0)
{
Image * image = new Image();
image->initWithImageFile(fullpath);
obj = image;
}
else
{
FILE * pFile = fopen(fullpath.c_str(), "r");
if (pFile != NULL)
{
// 获得文件大小
fseek(pFile, 0, SEEK_END);
uint32 size = ftell(pFile);
fseek(pFile, 0, SEEK_SET);
YHByteArray * bytes = new YHByteArray();
bytes->init(size);
fread(bytes->getBuffer(), size, 1, pFile);
obj = bytes;
fclose(pFile);
}
}
return obj;
}
示例4: getCells
CCArray* CGridView::getCells()
{
CCArray* pArray = new CCArray();
pArray->initWithCapacity(10);
if( !m_lCellsUsed.empty() )
{
list<CGridViewCell*>::iterator iter = m_lCellsUsed.begin();
for(; iter != m_lCellsUsed.end(); ++iter)
{
pArray->addObject(*iter);
}
}
pArray->autorelease();
return pArray;
}
示例5: getNodes
CCArray* CListView::getNodes()
{
CCArray* pArray = new CCArray();
pArray->initWithCapacity(10);
if( !m_vNodeList.empty() )
{
vector<CCNode*>::iterator iter = m_vNodeList.begin();
vector<CCNode*>::iterator iend = m_vNodeList.end();
for(; iter != iend; ++iter )
{
pArray->addObject(*iter);
}
}
pArray->autorelease();
return pArray;
}
示例6: CCArray
CCArray * CNSprite::createSprites(CCArray * pFilenames)
{
CCArray * pArray = new CCArray();
pArray->initWithCapacity(1);
CNSprite * pSprite = NULL;
CCObject * pObj = NULL;
CCString * pFilename;
CCARRAY_FOREACH(pFilenames, pObj)
{
pFilename = (CCString *)pObj;
pSprite = spriteWithFile(pFilename->getCString());
if (!pSprite)
{
CNLog("could not happen!");
continue;
}
pSprite->getTexture()->setAliasTexParameters();
pArray->addObject(pSprite);
}
示例7: executeTouchCancelledHandler
void CWidget::executeTouchCancelledHandler(CCTouch* pTouch, float fDuration)
{
if( m_pTouchCancelledListener && m_pTouchCancelledHandler )
{
if( !(m_pTouchCancelledListener->*m_pTouchCancelledHandler)(m_pThisObject, pTouch, fDuration) )
{
return;
}
}
#if USING_LUA
else if( m_nTouchCancelledScriptHandler != 0 )
{
CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();
CCLuaStack* pStack = pEngine->getLuaStack();
pStack->pushCCObject(m_pThisObject, "CCObject");
pStack->pushCCObject(pTouch, "CCTouch");
pStack->pushFloat(fDuration);
CCArray* pRetArray = new CCArray();
pRetArray->initWithCapacity(1);
int nRet = pStack->executeFunctionReturnArray(m_nTouchCancelledScriptHandler, 3, 1, pRetArray);
CCAssert(pRetArray->count() > 0, "return count = 0");
CCBool* pBool = (CCBool*) pRetArray->objectAtIndex(0);
bool bContinue = pBool->getValue();
delete pRetArray;
pStack->clean();
if(!bContinue)
{
return;
}
}
#endif
this->onTouchCancelled(pTouch, fDuration);
return;
}
示例8: if
CCObject * YHDataManagerImp::loadFile(const std::string & fullpath)
{
string suffix = pathExtensionWithString(fullpath);
asciiToLower(suffix);
// 装载对应的对象
CCObject * obj = NULL;
if (suffix.compare("plist-array") == 0)
{
ValueVector vv = CCFileUtils::getInstance()->getValueVectorFromFile(fullpath);
CCArray * arr = new CCArray();
arr->initWithCapacity((ssize_t)vv.size());
array_Value(arr, vv);
obj = arr;
}
else if (suffix.compare("plist-dictionary") == 0)
{
ValueMap vm = FileUtils::getInstance()->getValueMapFromFile(fullpath);
CCDictionary * dic = new CCDictionary();
dic->init();
dictionary_Value(dic, vm);
obj = dic;
}
else if (suffix.compare("png") == 0 || suffix.compare("jpg") == 0 || suffix.compare("jpeg") == 0
|| suffix.compare("tif") == 0 || suffix.compare("tiff") == 0 || suffix.compare("webp") == 0)
{
Image * image = new Image();
image->initWithImageFile(fullpath);
obj = image;
}
else if (suffix.compare("plist") == 0)
{
ValueMap vm = CCFileUtils::getInstance()->getValueMapFromFile(fullpath);
if (vm.size())
{
CCDictionary * dic = new CCDictionary();
dic->init();
dictionary_Value(dic, vm);
obj = dic;
}
else
{
ValueVector vv = CCFileUtils::getInstance()->getValueVectorFromFile(fullpath);
if (vv.size())
{
CCArray * arr = new CCArray();
arr->initWithCapacity((ssize_t)vv.size());
array_Value(arr, vv);
obj = arr;
}
else
{
CCASSERT(false, "没有找到适合的解析文件方式。");
}
}
}
else
{
std::string data = FileUtils::getInstance()->getStringFromFile(fullpath);
YHByteArray * bytes = new YHByteArray();
bytes->init(data.length() + 1);
bytes->writeBytes((char *)data.c_str(), data.length() + 1);
obj = bytes;
}
return obj;
}