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


C++ CCObject类代码示例

本文整理汇总了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;
    }
}
开发者ID:Siemnok,项目名称:Alarm-x4,代码行数:34,代码来源:CCHttpRequest.cpp

示例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;
        }
    }
}
开发者ID:AllenCoder,项目名称:EasyNDK-for-cocos2dx,代码行数:29,代码来源:NDKHelper.cpp

示例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>";
}
开发者ID:weimingtom,项目名称:guichan_cocos2dx,代码行数:28,代码来源:CCDataVisitor.cpp

示例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;
        }
    }
}
开发者ID:AllenCoder,项目名称:EasyNDK-for-cocos2dx,代码行数:28,代码来源:NDKHelper.cpp

示例5: getChildren

void CObjectBase::update(float dt)
{
    CCArray* children = getChildren();
    CCObject* pObj;
    CCARRAY_FOREACH(children, pObj)
    {
        pObj->update(dt);
    }
开发者ID:raymondma,项目名称:EliminationPlane,代码行数:8,代码来源:CObjectBase.cpp

示例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);
}
开发者ID:BetaS,项目名称:cocos2d-x,代码行数:8,代码来源:CCNotificationHandler.cpp

示例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);
     }
开发者ID:sergey-shambir,项目名称:cocos2d-x-jsonconverter,代码行数:9,代码来源:CCJSONConverter.cpp

示例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();
}
开发者ID:Dream-Hat,项目名称:mdsj,代码行数:10,代码来源:Facade.cpp

示例9: CCDICT_FOREACH

DBData::~DBData()
{
    CCDictElement* pElement = NULL;
    CCDICT_FOREACH(m_dic, pElement)
    {
        CCObject* pObj = pElement->getObject();
        if (pObj)
        {
            pObj->release();
        }
    }
开发者ID:Whislly,项目名称:DreamBookToolbox,代码行数:11,代码来源:DBData.cpp

示例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;
    }
}
开发者ID:NickYang,项目名称:Cocos2dxGAFPlayer,代码行数:11,代码来源:CCJSONConverter.cpp

示例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;
}
开发者ID:DeltaYang,项目名称:CrossApp,代码行数:48,代码来源:CAUIHelper.cpp

示例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();
	}
}
开发者ID:bontey,项目名称:geckosCocos2dxUtils,代码行数:16,代码来源:FloatTips.cpp

示例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 );
            }
        }
    }
}
开发者ID:CraftedCube,项目名称:playir,代码行数:18,代码来源:CCSceneBase.cpp

示例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);
        }
    }
}
开发者ID:echenonline,项目名称:Blackcat,代码行数:44,代码来源:AsyncLoadPlist.cpp

示例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;
}
开发者ID:CraftedCube,项目名称:playir,代码行数:23,代码来源:CCSceneBase.cpp


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