Esempio n. 1
0
void CHandBookPanel::updateShowArea()
{
	CCNode* pLayer = m_ui;

	if(m_pHeroLayer) m_pHeroLayer->setVisible(false);
	if(m_pMonsterLayer) m_pMonsterLayer->setVisible(false);
	if(m_pEquipLayer)m_pEquipLayer->setVisible(false);

	switch (m_iType)
	{
	case HandBookTabHero:
		{
			if(!m_pHeroLayer)
			{
				m_pHeroLayer = CHandBookHeroLayer::create();
				m_pHeroLayer->setTouchPriority(LayerManager::instance()->getPriority()-1);
				pLayer->addChild(m_pHeroLayer);
				m_pHeroLayer->setPosition(pLayer->convertToNodeSpace(m_pHeroLayer->getPosition()));
				AskForHandBook(m_iType);
			}
			else
			{
				m_pHeroLayer->setVisible(true);
			}
		}
		break;
	case HandBookTabMonster:
		{
			if(!m_pMonsterLayer)
			{
				m_pMonsterLayer = CHandBookMonsterLayer::create();
				m_pMonsterLayer->setTouchPriority(LayerManager::instance()->getPriority()-1);
				pLayer->addChild(m_pMonsterLayer);
				m_pMonsterLayer->setPosition(pLayer->convertToNodeSpace(m_pMonsterLayer->getPosition()));
				AskForHandBook(m_iType);
			}
			m_pMonsterLayer->setVisible(true);
		}
		break;
	case HandBookTabEquip:
		{
			if(!m_pEquipLayer)
			{
				m_pEquipLayer = CHandBookEquipLayer::create();
				m_pEquipLayer->setTouchPriority(LayerManager::instance()->getPriority()-1);
				pLayer->addChild(m_pEquipLayer);
				m_pEquipLayer->setPosition(pLayer->convertToNodeSpace(m_pEquipLayer->getPosition()));
				AskForHandBook(m_iType);
			}
			m_pEquipLayer->setVisible(true);
		}
		break;
	case HandBookTabMax:
		break;
	default:
		break;
	}
}
Esempio n. 2
0
void ScrollViewDemo::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)
{
	CCTouch *touch = (CCTouch*)pTouches->anyObject();
    CCNode *clipper = this->getChildByTag(kTagClipperNode);
	CCPoint point = clipper->convertToNodeSpace(CCDirector::sharedDirector()->convertToGL(touch->getLocationInView()));
    CCRect rect = CCRectMake(0, 0, clipper->getContentSize().width, clipper->getContentSize().height);
    m_bScrolling = rect.containsPoint(point);
    m_lastPoint = point;
}
Esempio n. 3
0
void ScrollViewDemo::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
{
    if (!m_bScrolling) return;
	CCTouch *touch = (CCTouch*)pTouches->anyObject();
    CCNode *clipper = this->getChildByTag(kTagClipperNode);
    CCPoint point = clipper->convertToNodeSpace(CCDirector::sharedDirector()->convertToGL(touch->getLocationInView()));
	CCPoint diff = ccpSub(point, m_lastPoint);
    CCNode *content = clipper->getChildByTag(kTagContentNode);
    content->setPosition( ccpAdd(content->getPosition(), diff) );
    m_lastPoint = point;
}
Esempio n. 4
0
bool CCtrlPage::isTouchInside( cocos2d::CCTouch * touch )
{
	CCNode* pParent = this->getParent();
	if (NULL == pParent)
	{
		return false;
	}

	CHECKF(touch);
	CCPoint touchLocation = touch->getLocation(); // Get the touch position
	touchLocation = pParent->convertToNodeSpace(touchLocation);
	CCRect bBox=boundingBox();
	return bBox.containsPoint(touchLocation);
}
Esempio n. 5
0
void Character::setWorldPos(CCPoint posInWorld)
{
    if(m_bodyArray.size() == 0)
        return ;
    b2Body* pBody = m_bodyArray[0];
    if(!pBody)
        return;
    pBody->SetTransform(b2Vec2(posInWorld.x/PTM_RATIO,posInWorld.y/PTM_RATIO), 0);
    CCSprite* pSprite =  (CCSprite*)pBody->GetUserData();
    if(!pSprite)
        return ;
    CCNode* pParent =pSprite->getParent();
    if(!pParent)
        return;
    CCPoint point = pParent->convertToNodeSpace(CCPointMake( posInWorld.x/PTM_RATIO,posInWorld.y/PTM_RATIO));
    pSprite->setPosition(point);
}
Esempio n. 6
0
void ConvertToNode::ccTouchesended(CCSet* touches, CCEvent *event)
{
    for( CCSetIterator it = touches->begin(); it != touches->end(); ++it)
    {
        CCTouch* touch = (CCTouch*)(*it);
        CCPoint location = touch->getLocation();

        for( int i = 0; i < 3; i++)
        {
            CCNode *node = getChildByTag(100+i);
            CCPoint p1, p2;

            p1 = node->convertToNodeSpaceAR(location);
            p2 = node->convertToNodeSpace(location);

            CCLOG("AR: x=%.2f, y=%.2f -- Not AR: x=%.2f, y=%.2f", p1.x, p1.y, p2.x, p2.y);
        }
    }    
}