Пример #1
0
void IOSStoreLayer::setADVisible(bool e, bool bRemove /* = false*/)
{
	if (!m_pBg)
	{
		return;
	}
	CCNode* pnode = m_pBg->getChildByTag(ad_tip_string_tag);
	if (pnode && pnode->isVisible() != e)
	{
		pnode->setVisible(e);
		if (bRemove)
		{
			pnode->removeFromParent();
		}
	}
	pnode = m_pBg->getChildByTag(ad_tip_bg_tag);
	if (pnode && pnode->isVisible() != e)
	{
		pnode->setVisible(e);
		if (bRemove)
		{
			pnode->removeFromParent();
		}
	}
}
Пример #2
0
void HeadUpDisplay::showMessage(){

	/* A visible MenuItem is enabled as a button, so in order to no repeat
	 * the action of this method, we check if the accept button was enabled. */
	CCNode* acceptButton = this->getChildByTag(_acceptButtonTag);
	if(acceptButton->isVisible())
		return;


	/* Applying animation to show message elements.  */
	acceptButton->setVisible(true);

	CCNode* mesh = this->getChildByTag(_meshTag);
	mesh->stopAllActions();
	mesh->runAction(CCFadeTo::create(.25f, 255 * .5f));

	CCNode* bubbleTalk = this->getChildByTag(_bubbleTalkTag);
	bubbleTalk->stopAllActions();
	bubbleTalk->runAction(
			CCSequence::create(
				CCScaleTo::create(.25f, 0.75f, 1.25f),
				CCScaleTo::create(.25f, 1.00f, 1.00f),
				NULL
			)
	);

	CCNode* message = bubbleTalk->getChildByTag(_messageTag);
	message->stopAllActions();
	message->runAction(CCFadeTo::create(.5f, 255));
}
Пример #3
0
bool CPullMachMenu::ccTouchBegan(CCTouch* touch, CCEvent* event)
{
	CC_UNUSED_PARAM(event);
	if (m_eState != kCCMenuStateWaiting || ! m_bVisible || !isEnabled())
	{
		return false;
	}

	for (CCNode *c = this->m_pParent; c != NULL; c = c->getParent())
	{
		if (c->isVisible() == false)
		{
			return false;
		}
	}

	m_pSelectedItem = this->itemForTouchPM(touch);
	if (m_pSelectedItem)
	{
		m_eState = kCCMenuStateTrackingTouch;
		m_pSelectedItem->selected();
		return true;
	}
	return false;
}
Пример #4
0
bool CWidgetLayout::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
{
	if( m_bTouchEnabled && m_bVisible && m_pChildren && m_pChildren->count() > 0 )
	{
		CCPoint touchPointInView = convertToNodeSpace(pTouch->getLocation());
		if( m_pChildren && m_pChildren->count() > 0 )
		{
			CCObject* pObject = NULL;
			CCARRAY_FOREACH_REVERSE( m_pChildren, pObject )
			{
				CCNode* pNode = dynamic_cast<CCNode*>(pObject);
				CWidget* pWidget = dynamic_cast<CWidget*>(pObject);
				if( pWidget && pNode->isVisible() && pWidget->isEnabled() && pWidget->isTouchEnabled() )
				{
					if( pNode->boundingBox().containsPoint(touchPointInView) )
					{
						if( pWidget->executeTouchBeganHandler(pTouch) != eWidgetTouchNone )
						{
							m_pSelectedWidget = pWidget;
							m_bIsTouched = true;
							m_fTouchedDuration = 0.0f;
							return true;
						}
					}
				}
			}
Пример #5
0
	void updateScroll(){
		bool vBar = _scrollBar && _scrollBar->isVisible(),
			vNode = _scrollNode && _scrollNode->isVisible();
		if(!vBar || !vNode){
			return;
		}
		bool vert = getDirection() == kCCScrollViewDirectionVertical;
		CCPoint p, cp = getContentOffset();
		CCSize vs = getViewSize(),
			cs = getContentSize();
		float rate = 1 - (vert? fabsf(cp.y) / (cs.height - vs.height) : fabsf(cp.x) / (cs.width - vs.width));
		if(vBar){
			CCSize ss = _scrollBar->getPreferredSize();
			p = _scrollBar->getPosition();
			if(vert){	p.y = cs.height - (cs.height - ss.height) * rate - ss.height - _scrollTrackDelta;
			}else{		p.x = cs.width - (cs.width - ss.width) * rate - ss.width - _scrollTrackDelta;
			}
			_scrollBar->setPosition(p);
		}
		if(vNode){
			p = _scrollNode->getPosition();
			if(vert){	p.y = cp.y + vs.height * rate;
			}else{		p.x = cp.x + vs.width * rate;
			}
			_scrollNode->setPosition(p);
		}
		if(_scrollTrack){
			p = _scrollTrack->getPosition();
			if(vert){	p.y = fabsf(cp.y);
			}else{		p.x = fabsf(cp.x);
			}
			_scrollTrack->setPosition(p);
		}
//CCLog("LuaTableView.updateScroll ss=%d,%d vh=%d cy=%d ch=%d y=%d", (int)ss.width, (int)ss.height, (int)vs.height, (int)p.y, (int)cs.height, (int)_scrollBar->getPositionY());
	}
Пример #6
0
bool MDragDownView::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
{
    if (isVisible() == false)
    {
        return false;
    }
    
    for (CCNode *c = this->m_pParent; c != NULL; c = c->getParent())
    {
        if (c->isVisible() == false)
        {
            return false;
        }
    }

    updateRect();
    m_touchBeginPosition = pTouch->getLocation();
    
    if (m_viewRect.containsPoint(m_touchBeginPosition) == false)
    {
        return false;
    }
    
    
    if (m_eState != State::NONE)
    {
        return true;
    }
    
    m_isTouchDragBar = m_pDragBar ? m_dragBarRect.containsPoint(m_touchBeginPosition) : false;
    m_viewOldSize = m_viewSize;
    
    return true;
}
Пример #7
0
bool NewMenuDevice::ccTouchBegan(cocos2d::CCTouch *touch, cocos2d::CCEvent *event) {
    //    CCPoint pouchT = map->transScreenToMap(ccp(pTouch->locationInView().x,pTouch->locationInView().y));
    //    CCPoint posiT = map->transMapToTiled(this->getPosition());
    //        
    //    CCPoint tiled = map->transMapToTiled(pouchT);
    //    if(Mathlib::inBound(tiled.x, posiT.x+contentSizeByTiled.width/2, posiT.x-contentSizeByTiled.width/2) &&
    //           Mathlib::inBound(tiled.y, posiT.y+contentSizeByTiled.height/2, posiT.y-contentSizeByTiled.height/2)) {
    //        isMoved = true;
    //    }
    //    return CCMenu::ccTouchBegan(pTouch, pEvent);
    
    CC_UNUSED_PARAM(event);
    if (m_eState != kCCMenuStateWaiting || ! m_bVisible || !isEnabled())
    {
        return false;
    }
    
    for (CCNode *c = this->m_pParent; c != NULL; c = c->getParent())
    {
        if (c->isVisible() == false)
        {
            return false;
        }
    }
    
    m_pSelectedItem = this->itemForTouch(touch);
    if (m_pSelectedItem)
    {
        m_eState = kCCMenuStateTrackingTouch;
        m_pSelectedItem->selected();
        return true;
    }
    return false;
    
}
bool LsTouch::isParentAllVisible(LsTouchEvent* lsTe)
{
    bool bRef = true;
    CCNode* nLsTe = dynamic_cast<CCNode*>(lsTe);
    CCNode* parent = getParent();
    do
    {
        if (!parent)
        {
            bRef = false;
            break;
        }
        if (nLsTe == parent)
        {
            break;
        }
        if (!parent->isVisible())
        {
            bRef = false;
            break;
        }
        parent = parent->getParent();
    } while (1);

    return bRef;
}
//-------------------------------------------------------------------------
ENUM_WidgetTouchModel FKCW_UIWidget_Layout::onTouchBegan(CCTouch* pTouch)
{
	m_pSelectedWidget = NULL;
	m_eSelectedWidgetTouchModel = eWidgetTouchNone;

	CCPoint tNodePoint = convertToNodeSpace(pTouch->getLocation());
	if( m_pChildren && m_pChildren->count() > 0 )
	{
		CCObject* pObject = NULL;
		CCARRAY_FOREACH_REVERSE( m_pChildren, pObject )
		{
			CCNode* pNode = dynamic_cast<CCNode*>(pObject);
			FKCW_UIWidget_Widget* pWidget = dynamic_cast<FKCW_UIWidget_Widget*>(pObject);
			if( pWidget && pNode->isVisible() && pWidget->isEnabled() && pWidget->isTouchEnabled() )
			{
				if( pNode->boundingBox().containsPoint(tNodePoint) )
				{
					m_eSelectedWidgetTouchModel = pWidget->executeTouchBeganHandler(pTouch);
					if( m_eSelectedWidgetTouchModel == eWidgetTouchNone )
					{
						m_pSelectedWidget = NULL;
						m_eSelectedWidgetTouchModel = eWidgetTouchNone;
					}
					else
					{
						m_pSelectedWidget = pWidget;
						return m_eSelectedWidgetTouchModel;
					}
				}
			}
		}
Пример #10
0
bool LsTouch::isParentAllVisible(LsTouchEvent* lsTe) {
	bool bRef = true;
	// 向父类转型,以便获取地址比较对象,LsTouchEvent 的对象必须同时直接或者简介继承 CCNode
	CCNode* nLsTe = dynamic_cast<CCNode*>(lsTe);

	CCNode* parent = getParent();
	do {
		// 如果遍历完毕,说明 LsTouch 不再 LsTouchEvent 之内
		if (!parent) {
			bRef = false;
			break;
		}
		// 如果 LsTouch 在 LsTouchEvent 之内,返回 true
		// 注意:如果想让LsTouchEvent 处理 不在其 CCNode 结构之内的元素,则取消此处判断
		if (nLsTe == parent) {
			break;
		}
		if (!parent->isVisible()) {
			bRef = false;
			break;
		}
		parent = parent->getParent();
	} while (1);
	return bRef;
}
Пример #11
0
bool NodeVisible::detect()
{
	CCNode *pNode = SceneReader::sharedSceneReader()->getNodeByTag(_nTag);
	if (pNode != NULL && pNode->isVisible() == _bVisible)
	{
		return true;
	}
	return false;
}
Пример #12
0
bool Component::hasVisibleParents()
{
    CCNode* pParent = this->getParent();
    for( CCNode *c = pParent; c != NULL; c = c->getParent() )
    {
        if( !c->isVisible() )
        {
            return false;
        }
    }
    return true;
}
Пример #13
0
	void UIScrollLayer::ccTouchMoved(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent)
	{
		// Òƶ¯
		CCPoint touchPoint = CCDirector::sharedDirector()->convertToGL(pTouch->getLocationInView());

		if(!touchIsInContent(touchPoint) || !m_bVisible)
		{
			return;
		}		

		for (CCNode *c = this->m_pParent; c != NULL; c = c->getParent())
		{
			if (c->isVisible() == false)
			{
				return;
			}
		}

		CCPoint ptbaselayer = m_baseLayer->getPosition();

		if (m_ScrollDir == ESD_Horizontal)
		{
			CCPoint posPoint = CCPointMake(m_baseLayer->getPosition().x + touchPoint.x - m_TouchCurPoint.x, ptbaselayer.y);

			if(abs(touchPoint.x - m_TouchCurPoint.x) > TOUCH_DELTA)
			{
				m_bShouldStolenTouch = true;
			}
			if(abs(touchPoint.x - m_TouchDownPoint.x) > MIN_MOVE_DELTA)
			{
				m_baseLayer->setPosition(posPoint);
			}
		}
		else
		{
			CCPoint posPoint = CCPointMake(ptbaselayer.x, m_baseLayer->getPosition().y + touchPoint.y - m_TouchCurPoint.y);

			if(abs(touchPoint.y - m_TouchCurPoint.y) > TOUCH_DELTA)
			{
				m_bShouldStolenTouch = true;
			}
			if(abs(touchPoint.y - m_TouchDownPoint.y) > MIN_MOVE_DELTA)
			{
				m_baseLayer->setPosition(posPoint);
			}
		}
    
		m_TouchCurPoint = touchPoint;
		m_ScrollStatus = ESS_DRAGGING;
	}
Пример #14
0
bool MyMenu::ccTouchBegan(cocos2d::CCTouch *touch, cocos2d::CCEvent *event) {
    if (isActive) {
        cacheTouch  = map->transMapToTiled(map->convertToNodeSpace(touch->getLocation()));
        if (CCMenu::ccTouchBegan(touch, event)) {
//            if (m_pSelectedItem->getTag() == myTiledMenuItemTag) {
//                moveEnabled = true;
//                isMoved = false;
//                //TODO
////                ((MyMap*)map)->moveTemp = this;
//                MyMenu::reorderZandTouchPriority(1000000, -499);
//            } else {
////                ((MyMap*)map)->moveTemp = this;
//                moveEnabled = false;
//                isMoved = false;
//            }
            return true;
        }
        return false;
    }
    if (((MyMap*)map)->isBuild()) {
        return false;
    }
    CC_UNUSED_PARAM(event);
    if (m_eState != kCCMenuStateWaiting || ! m_bVisible || !isEnabled())
    {
        return false;
    }
    
    for (CCNode *c = this->m_pParent; c != NULL; c = c->getParent())
    {
        if (c->isVisible() == false)
        {
            return false;
        }
    }
    
    m_pSelectedItem = this->itemForTouch(touch);
    if (m_pSelectedItem)
    {
        m_eState = kCCMenuStateTrackingTouch;
        m_pSelectedItem->selected();
        return true;
    }
    return false;

}
Пример #15
0
void switchImages(ADMenuItem* item)
{
    CCNode* normal = item->getChildByTag(NORMAL_SPRITE);
    CCNode* selected = item->getChildByTag(SELECTED_SPRITE);

    if(normal && selected)
    {
        if(normal->isVisible())
        {
            normal->setVisible(false);
            selected->setVisible(true);
        }
        else
        {
            normal->setVisible(true);
            selected->setVisible(false);
        }
    }
}
Пример #16
0
void IOSStoreLayer::scrollViewDidScroll(CCScrollView* view)
{
	CCLog("scroll....");
	CCLog("scroll %f, %f", view->getContentOffset().x, view->getContentOffset().y);
	CCNode* pnodeLeft = m_pBuyStarNode->getChildByTag(left_arrow_tag);
	CCNode* pnodeRight = m_pBuyStarNode->getChildByTag(right_arrow_tag);
	CCPoint point = view->getContentOffset();
	if (!pnodeLeft || !pnodeRight)
	{
		return;
	}
	//显示左边隐藏右边
	if (point.x <= -210)
	{
		if (!pnodeLeft->isVisible())
		{
			pnodeLeft->setVisible(true);
		}
		if (pnodeRight->isVisible())
		{
			pnodeRight->setVisible(false);
		}
	}
	//隐藏左边显示右边
	else if (point.x >= 0)
	{
		if (pnodeLeft->isVisible())
		{
			pnodeLeft->setVisible(false);
		}
		if (!pnodeRight->isVisible())
		{
			pnodeRight->setVisible(true);
		}
	}
	//左右都显示
	else
	{
		if (!pnodeLeft->isVisible())
		{
			pnodeLeft->setVisible(true);
		}
		if (!pnodeRight->isVisible())
		{
			pnodeRight->setVisible(true);
		}
	}
}
Пример #17
0
	bool UIScrollLayer::ccTouchBegan(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent)
	{
		CCPoint touchPoint = pTouch->getLocationInView();
		m_TouchDownPoint = CCDirector::sharedDirector()->convertToGL(touchPoint);

		if(!touchIsInContent(m_TouchDownPoint) || !m_bVisible)
		{
			return false;
		}		
		
		for (CCNode *c = this->m_pParent; c != NULL; c = c->getParent())
		{
			if (c->isVisible() == false)
			{
				return false;
			}
		}

		m_TouchCurPoint = m_TouchDownPoint;
		m_ScrollStatus = ESS_TOUCHED;
    
		return true;
	}
Пример #18
0
bool CCScene::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
{
    CC_SAFE_RELEASE_NULL(m_touchNode);
    const CCPoint p = pTouch->getLocation();
    CCObject *node;
    CCNode *touchNode = NULL;
    CCNode *checkNode = NULL;
    bool visible = true;
    sortAllTouchableNodes();
    CCARRAY_FOREACH(m_touchableNodes, node)
    {
        checkNode = touchNode = dynamic_cast<CCNode*>(node);

        // check node is visible
        visible = true;
        do
        {
            visible = visible && checkNode->isVisible();
            checkNode = checkNode->getParent();
        } while (checkNode && visible);
        if (!visible) continue;

        const CCRect boundingBox = touchNode->getCascadeBoundingBox();
        if (boundingBox.containsPoint(p))
        {
            touchNode->retain();
            bool ret = touchNode->ccTouchBegan(pTouch, pEvent);
            if (ret && touchNode->isRunning())
            {
                m_touchNode = touchNode;
                m_touchNode->retain();
            }
            touchNode->release();
            if (ret) return true;
        }
    }
Пример #19
0
void CCScene::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)
{
    if (!m_touchDispatchingEnabled) return;

    // cleanup
    m_touchingTargets->removeAllObjects();

    // sort touchable nodes
    sortAllTouchableNodes(m_touchableNodes);

    // find touching target
    bool isTouchable = true;
    CCObject *obj = NULL;
    CCNode *node = NULL;
    CCNode *checkTouchableNode = NULL;
    CCTouchTargetNode *touchTarget = NULL;

    CCARRAY_FOREACH(m_touchableNodes, obj)
    {
        checkTouchableNode = node = dynamic_cast<CCNode*>(obj);

        // check node is visible and capturing enabled
        isTouchable = true;
        do
        {
            isTouchable = isTouchable
                    && checkTouchableNode->isRunning()
                    && checkTouchableNode->isVisible()
                    && checkTouchableNode->isTouchCaptureEnabled();
            checkTouchableNode = checkTouchableNode->getParent();
        } while (checkTouchableNode && isTouchable);
        if (!isTouchable) continue;

        // prepare for touch testing
        touchTarget = NULL;
        const CCRect boundingBox = node->getCascadeBoundingBox();

        // set touch target
        CCTouch *touch = NULL;
        for (CCSetIterator it = pTouches->begin(); it != pTouches->end(); ++it)
        {
            touch = (CCTouch*)*it;
            const CCPoint touchPoint = touch->getLocation();

            if (boundingBox.containsPoint(touchPoint))
            {
                if (!touchTarget)
                {
                    touchTarget = CCTouchTargetNode::create(node);
                }

                if (touchTarget->getTouchMode() == kCCTouchesOneByOne)
                {
                    touchTarget->setTouchId(touch->getID());
                    break;
                }
            }
        }

        if (!touchTarget)
        {
            // touch points not in current target, try to next
            continue;
        }

        // try to dispatching event
        CCArray *path = CCArray::createWithCapacity(10);
        node = touchTarget->getNode();
        do
        {
            path->addObject(node);
            node = node->getParent();
        } while (node != NULL && node != this);

        // phase: capturing
        // from parent to child
        bool dispatchingContinue = true;
        int touchMode = touchTarget->getTouchMode();
        for (int i = path->count() - 1; dispatchingContinue && i >= 0; --i)
        {
            node = dynamic_cast<CCNode*>(path->objectAtIndex(i));
            if (touchMode == kCCTouchesAllAtOnce)
            {
                node->ccTouchesCaptureBegan(pTouches, touchTarget->getNode());
            }
            else
            {
                dispatchingContinue = node->ccTouchCaptureBegan(touchTarget->findTouch(pTouches), touchTarget->getNode());
            }
        }

        if (!dispatchingContinue)
        {
            // the target stop dispatching, try to next
            continue;
        }

        // phase: targeting
        node = touchTarget->getNode();
        bool ret = true;
        if (touchMode == kCCTouchesAllAtOnce)
        {
            node->ccTouchesBegan(pTouches, pEvent);
        }
        else
        {
            ret = node->ccTouchBegan(touchTarget->findTouch(pTouches), pEvent);
        }

        if (ret)
        {
            m_touchingTargets->addObject(touchTarget);
//            CCLOG("ADD TOUCH TARGET [%p]", touchTarget);
        }

        if (node->isTouchSwallowEnabled())
        {
            // target swallow touch event, stop dispatching
            break;
        }

        // continue dispatching, try to next
    }