Пример #1
0
void CCBProxy::setCallback(CCNode* pNode,int nHandle,int nControlEvents)
{
    if (NULL == pNode) {
        return;
    }
    
    if (NULL != dynamic_cast<CCMenuItem*>(pNode))
    {
        CCMenuItem *pMenuItem = dynamic_cast<CCMenuItem*>(pNode);
        if (NULL != pMenuItem) {
            pMenuItem->registerScriptTapHandler(nHandle);
        }
    }
    else  if (NULL != dynamic_cast<CCControl*>(pNode))
    {
        
        CCControl* pControl = dynamic_cast<CCControl*>(pNode);
        if (NULL != pControl)
        {
            for (int i = 0; i < kControlEventTotalNumber; i++)
            {
                if ((nControlEvents & (1 << i)))
                {
                    pControl->addHandleOfControlEvent(nHandle, 1 << i);
                }
            }
        }
    }
}
Пример #2
0
void HTouchEnabledLayerColor::setPriority(CCNode *node, int priority) {
    if (dynamic_cast<CCControl *>(node)) {
        CCControl *control = (CCControl *)node;
        control->setTouchPriority(priority);
        if (control->isTouchEnabled()) {
            control->setTouchEnabled(false);
            control->setTouchEnabled(true);
        }
    } else if (dynamic_cast<CCScrollView *>(node)) {
        CCScrollView *scrollView = (CCScrollView *)node;
        scrollView->setTouchPriority(priority);
        if (scrollView->isTouchEnabled()) {
            scrollView->setTouchEnabled(false);
            scrollView->setTouchEnabled(true);
        }
    } else if (dynamic_cast<CCMenu *>(node)) {
        CCMenu *menu = (CCMenu *)node;
        menu->setTouchPriority(priority);
        if (menu->isTouchEnabled()) {
            menu->setTouchEnabled(false);
            menu->setTouchEnabled(true);
        }
    } else if (dynamic_cast<CCLayer *>(node)) {
        CCLayer *layer = (CCLayer *)node;
        layer->setTouchPriority(priority);
        if (layer->isTouchEnabled()) {
            layer->setTouchEnabled(false);
            layer->setTouchEnabled(true);
        }
    }
}
Пример #3
0
CCControl* CCControl::create()
{
    CCControl* pRet = new CCControl();
    if (pRet && pRet->init())
    {
        pRet->autorelease();
        return pRet;
    }
    else
    {
        CC_SAFE_DELETE(pRet);
        return NULL;
    }
}
Пример #4
0
CCControl* CCControl::create()
{
    CCControl* pRet = new CCControl();
    if (pRet && pRet->init())
    {
		//DuongNT: assign v8 obj here
        pRet->assignJavaScriptObject(CLS_CCCONTROL_ID, false);
        pRet->autorelease();
        return pRet;
    }
    else
    {
        CC_SAFE_DELETE(pRet);
        return NULL;
    }
}
Пример #5
0
CCObject *HTouchEnabledLayerColor::updatePriorityEx(int command, CCNode *node) {
    int iBasePriority = getTouchPriority();
    
    if (dynamic_cast<CCControl *>(node)) {
        CCControl *control = (CCControl *)node;
        int priority = control->getTouchPriority();
        priority = iBasePriority - 9;
        control->setTouchPriority(priority);
        if (control->isTouchEnabled()) {
            control->setTouchEnabled(false);
            control->setTouchEnabled(true);
        }
    } else if (dynamic_cast<CCScrollView *>(node)) {
        CCScrollView *scrollView = (CCScrollView *)node;
        int priority = scrollView->getTouchPriority();
        priority = iBasePriority - 11;
        scrollView->setTouchPriority(priority);
        if (scrollView->isTouchEnabled()) {
            scrollView->setTouchEnabled(false);
            scrollView->setTouchEnabled(true);
        }
    } else if (dynamic_cast<CCMenu *>(node)) {
        CCMenu *menu = (CCMenu *)node;
        int priority = menu->getTouchPriority();
        priority = iBasePriority - 128;
        menu->setTouchPriority(priority);
        if (menu->isTouchEnabled()) {
            menu->setTouchEnabled(false);
            menu->setTouchEnabled(true);
        }
    } else if (dynamic_cast<CCLayer *>(node)) {
        CCLayer *layer = (CCLayer *)node;
        int priority = layer->getTouchPriority();
        priority = iBasePriority;
        layer->setTouchPriority(priority);
        if (layer->isTouchEnabled()) {
            layer->setTouchEnabled(false);
            layer->setTouchEnabled(true);
        }
    }

    CCArray *children = node->getChildren();
    if (children) {
        int count = children->count();
        for (int i = 0; i < count; ++i) {
            CCNode *child = (CCNode *)children->objectAtIndex(i);
            updatePriorityEx(command, child);
        }
    }
    
    return NULL;
}