本文整理汇总了C++中CCObject类的典型用法代码示例。如果您正苦于以下问题:C++ CCObject类的具体用法?C++ CCObject怎么用?C++ CCObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CCObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pthread_mutex_lock
//Poll and notify main thread if responses exists in queue
void CCHttpRequest::httpRequestCallback(float delta)
{
delta;
std::queue<HttpResponsePacket *> *pQueue = s_responseQueue;
pthread_mutex_lock(&s_responseQueueMutex);
if (pQueue->empty()) {
pthread_mutex_unlock(&s_responseQueueMutex);
} else {
HttpResponsePacket *packet = pQueue->front();
pQueue->pop();
pthread_mutex_unlock(&s_responseQueueMutex);
--s_asyncRequestCount;
if (0 == s_asyncRequestCount) {
CCDirector::sharedDirector()->getScheduler()->unscheduleSelector(schedule_selector(CCHttpRequest::httpRequestCallback), this);
}
HttpRequestPacket *orgRequest = packet->request;
CCObject *pTarget = orgRequest->pTarget;
SEL_CallFuncND pSelector = orgRequest->pSelector;
if (pTarget && pSelector) {
(pTarget->*pSelector)((CCNode *)this, packet);
pTarget->release();
}
delete orgRequest;
delete packet;
}
}
示例2: json_string_value
void NDKHelper::HandleMessage(json_t *methodName, json_t* methodParams)
{
if (methodName == NULL)
return;
const char *methodNameStr = json_string_value(methodName);
for (unsigned int i = 0; i < NDKHelper::selectorList.size(); ++i)
{
if (NDKHelper::selectorList[i].getName().compare(methodNameStr) == 0)
{
CCObject *dataToPass = NDKHelper::GetCCObjectFromJson(methodParams);
if (dataToPass != NULL)
dataToPass->retain();
SEL_CallFuncND sel = NDKHelper::selectorList[i].getSelector();
CCNode *target = NDKHelper::selectorList[i].getTarget();
CCFiniteTimeAction* action = CCSequence::create(CCCallFuncND::create(target, sel, (void*)dataToPass), NULL);
target->runAction(action);
if (dataToPass != NULL)
dataToPass->autorelease();
break;
}
}
}
示例3: setIndentLevel
void CCPrettyPrinter::visit(const CCArray *p)
{
_result += "\n";
_result += _indentStr;
_result += "<array>\n";
setIndentLevel(_indentLevel+1);
CCObject* obj;
int i = 0;
char buf[50] = {0};
CCARRAY_FOREACH(p, obj)
{
if (i > 0) {
_result += "\n";
}
sprintf(buf, "%s%02d: ", _indentStr.c_str(), i);
_result += buf;
CCPrettyPrinter v(_indentLevel);
obj->acceptVisitor(v);
_result += v.getResult();
i++;
}
setIndentLevel(_indentLevel-1);
_result += "\n";
_result += _indentStr;
_result += "</array>";
}
示例4: json_string_value
void NDKHelper::HandleMessage(json_t *methodName, json_t* methodParams)
{
if (methodName == NULL)
return;
const char *methodNameStr = json_string_value(methodName);
for (unsigned int i = 0; i < selectorList.size(); ++i)
{
if (selectorList[i].getName().compare(methodNameStr) == 0)
{
CCObject *dataToPass = NDKHelper::GetCCObjectFromJson(methodParams);
if (dataToPass != NULL)
dataToPass->retain();
SEL_CallFuncO sel = selectorList[i].getSelector();
CCObject *target = selectorList[i].getTarget();
callfuncs->addObject(CCCallFuncO::create(target, sel, dataToPass));
CCDirector::sharedDirector()->getScheduler()->scheduleSelector(schedule_selector(NDKHelper::ExecuteCallfuncs), this, 0, 0, 0, false);
if (dataToPass != NULL)
dataToPass->autorelease();
break;
}
}
}
示例5: getChildren
void CObjectBase::update(float dt)
{
CCArray* children = getChildren();
CCObject* pObj;
CCARRAY_FOREACH(children, pObj)
{
pObj->update(dt);
}
示例6: CCNotificationHandler
void CCNotificationHandler::postNotificationOnMainThread(const char *name, CCObject *object)
{
CCObject *target = new CCNotificationHandler(name, object);
target->retain();
target->autorelease();
CCDirector::sharedDirector()->getScheduler()->scheduleSelector(schedule_selector(CCNotificationHandler::postNotification), target, 0, 0, 0, false);
}
示例7: visit
virtual void visit(const CCArray *p)
{
cJSON *json = cJSON_CreateArray();
CCObject *obj = NULL;
CCARRAY_FOREACH(p, obj){
obj->acceptVisitor(*this);
if (m_json)
cJSON_AddItemToArray(json, m_json);
}
示例8: clear
void Facade::clear()
{
map<int,CCObject*>::iterator iter;
for (iter=mediatorVector.begin();iter!=mediatorVector.end();iter++)
{
CCObject* r = iter->second;
r->release();
}
mediatorVector.clear();
}
示例9: CCDICT_FOREACH
DBData::~DBData()
{
CCDictElement* pElement = NULL;
CCDICT_FOREACH(m_dic, pElement)
{
CCObject* pObj = pElement->getObject();
if (pObj)
{
pObj->release();
}
}
示例10: while
void CCJSONConverter::convertJsonToDictionary(cJSON *json, CCDictionary *dictionary)
{
dictionary->removeAllObjects();
cJSON * j = json->child;
while (j) {
CCObject * obj = getJsonObj(j);
dictionary->setObject(obj, j->string);
obj->release();
j = j->next;
}
}
示例11: CCLog
CCDictionary* CAUIHelper::createCAWidgetWithJsonFile(const char *filename)
{
std::string fullpath= CCFileUtils::sharedFileUtils()->fullPathForFilename(filename);
CCLog("%s",fullpath.c_str());
unsigned long size = 0;
char *des = (char*) CCFileUtils::sharedFileUtils()->getFileData(filename, "r", &size);
CSJson::Reader reader;
CSJson::Value root;
CSJson::Value description;
CSJson::Value rect;
CCObject *ui = new CCObject();
if (!reader.parse(des, root))
{
CCLog("error");
return NULL;
}
CCLog("%s",des);
for (int i = 0; i<root.size(); i++)
{
description = root[i];
CAType type = (CAType)description["typeMode"].asInt();
rect = description["rect"];
std::string name = description["name"].asString();
float width = rect["width"].asFloat();
float height = rect["height"].asFloat();
float x = rect["x"].asFloat();
float y = rect ["y"].asFloat();
CCRect uirect = CCRectMake(x, y, width, height);
// ui=CAButton::createWithFrame(CCRectMake(x, y, width, height));
if (type == CATypeButton)
{
ui = addButton(description, uirect);
}
else if(type == CATypeLabel)
{
ui = addLabel(description, uirect);
}
else if(type == CATypeImage)
{
}
m_UIDictionary->setObject(ui, name.c_str());
}
ui->release();
return m_UIDictionary;
}
示例12: clear
void FloatTips::clear()
{
if(ftPool)
{
CCObject* ft;
int count = ftPool->count();
for (int i = 0; i < count; i++)
{
ft = ftPool->objectAtIndex(i);
//谁retain谁就负责release
ft->release();
CCLOG("retainCount %i", ft->retainCount());
}
ftPool->removeAllObjects();
}
}
示例13: profile
void CCSceneBase::renderObjects(const CCCameraBase *inCamera, const CCRenderPass pass, const bool alpha)
{
#if defined PROFILEON
CCProfiler profile( "CCSceneBase::renderObjects()" );
#endif
for( int i=0; i<objects.length; ++i )
{
CCObject *object = objects.list[i];
if( object->renderPass == pass )
{
if( object->isActive() && ( object->octreeRender == false ) )
{
object->renderObject( inCamera, alpha );
}
}
}
}
示例14: pthread_mutex_lock
void AsyncLoadPlist::loadPlistAsyncCallBack(float dt)
{
// the image is generated in loading thread
std::queue<ImageInfo*> *imagesQueue = s_pImageQueue;
pthread_mutex_lock(&s_ImageInfoMutex);
if (imagesQueue->empty())
{
pthread_mutex_unlock(&s_ImageInfoMutex);
}
else
{
ImageInfo *pImageInfo = imagesQueue->front();
imagesQueue->pop();
pthread_mutex_unlock(&s_ImageInfoMutex);
LoadStruct *pLoadStruct = pImageInfo->loadStruct;
CCImage *pImage = pImageInfo->image;
CCObject *target = pLoadStruct->target;
SEL_CallFuncO selector = pLoadStruct->selector;
std::string texturePath = pLoadStruct->texturePath;
// 从texturePath中取文件名 如/../../filename.png 则filename.png
std::string textureFileName = texturePath.substr(texturePath.rfind('/') + 1);
CCTextureCache::sharedTextureCache()->addUIImage(pImage, textureFileName.c_str());
if (target && selector)
{
(target->*selector)(CCString::create(pLoadStruct->plistFileName));
target->release();
}
pImage->release();
delete pLoadStruct;
delete pImageInfo;
--s_nAsyncRefCount;
if (0 == s_nAsyncRefCount)
{
CCDirector::sharedDirector()->getScheduler()->unscheduleSelector(schedule_selector(AsyncLoadPlist::loadPlistAsyncCallBack), this);
}
}
}
示例15: updateScene
bool CCSceneBase::updateScene(const CCTime &time)
{
bool updated = false;
for( int i=0; i<objects.length; ++i )
{
CCObject *object = objects.list[i];
if( object->isActive() )
{
updated |= object->update( time );
}
else if( object->deleteMe > 0 )
{
if( --object->deleteMe == 0 )
{
DELETE_OBJECT( object );
--i;
}
}
}
return updated;
}