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


C++ CCLabelTTF::getTag方法代码示例

本文整理汇总了C++中CCLabelTTF::getTag方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLabelTTF::getTag方法的具体用法?C++ CCLabelTTF::getTag怎么用?C++ CCLabelTTF::getTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCLabelTTF的用法示例。


在下文中一共展示了CCLabelTTF::getTag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ccTouchesBegan

void LCCrossMatchGame::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)
{
	// 멀티터치 금지
	if (singleTouch != NULL) 
	{
		return;
	}
	
	CCTouch *touch = (CCTouch*)pTouches->anyObject();
	singleTouch = touch;
	
	prevTouchLocation = touch->locationInView( touch->view() );

	moveAmount = 0;
	
	m_pTouchedDotSprite = NULL;
	for (int i=0; i<m_pDotSprites->count(); i++) {
		CCSprite *dotSprite = (CCSprite *)m_pDotSprites->objectAtIndex(i);
		if (LCUtil::isTouchInside(dotSprite, pTouches)) {
			m_pTouchedDotSprite = dotSprite;
			break;
		}
	}
	
	// image touch 및 text label touch 구역 추가 on 11.10.17
	if (!m_pTouchedDotSprite) {
		for (int i=0; i<m_pImageArray->count(); i++) {
			CCSprite *imageSprite = (CCSprite *)m_pImageArray->objectAtIndex(i);
			if (LCUtil::isTouchInside(imageSprite, pTouches)) {
				// dotArray에 이미지 부분부터 추가되므로
				for (int i=0; i<m_pDotSprites->count(); i++) {
					CCSprite *dotSprite = (CCSprite *)m_pDotSprites->objectAtIndex(i);
					if (dotSprite->getTag() == imageSprite->getTag()) {
						m_pTouchedDotSprite = dotSprite;
						break;
					}
				}
			}
		}
	}
	
	if (!m_pTouchedDotSprite) {
		for (int i=0; i<m_pTextArray->count(); i++) {
			CCLabelTTF *textLabel = (CCLabelTTF*)m_pTextArray->objectAtIndex(i);
			if (LCUtil::isTouchInside(textLabel, pTouches)) {
				// dotArray에 이미지 부분부터 추가되므로 뒤에서부터 탐색
				for (int i=m_pDotSprites->count()-1; i>=0; i--) {
					CCSprite *dotSprite = (CCSprite *)m_pDotSprites->objectAtIndex(i);
					if (dotSprite->getTag() == textLabel->getTag()) {
						m_pTouchedDotSprite = dotSprite;
						break;
					}
				}
			}
		}
	}
}
开发者ID:,项目名称:,代码行数:57,代码来源:

示例2: ccTouchesEnded

void LCCrossMatchGame::ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent)
{
	if (m_pTouchedDotSprite) {
		CCSprite *matchedDotSprite = NULL;
		bool isTouchedIncorrectly = false;
		
		// 다른 점을 터치 했는지 체크
		for (int i=0; i<m_pDotSprites->count(); i++) {
			CCSprite *dotSprite = (CCSprite *)m_pDotSprites->objectAtIndex(i);
			if (m_pTouchedDotSprite == dotSprite) {
				continue;
			}
			if (LCUtil::isTouchInside(dotSprite, pTouches)) {
				//move dots from dot array to finished dot array
				if (dotSprite->getTag() == m_pTouchedDotSprite->getTag()) {
					matchedDotSprite = dotSprite;
				}else {
					isTouchedIncorrectly = true;
				}
				
				break;
			}
		}
		
		// image touch 및 text label touch 구역 추가 on 11.10.17
		if (!matchedDotSprite && !isTouchedIncorrectly) {
			int index = m_pDotSprites->indexOfObject(m_pTouchedDotSprite);
			
			if (index < m_pDotSprites->count() / 2) {
				// 앞쪽에 있는 것은 image 부분에 있는 점 => text부분 터치 체크
				for (int i=0; i<m_pTextArray->count(); i++) {
					CCLabelTTF *textLabel = (CCLabelTTF*)m_pTextArray->objectAtIndex(i);
					if (LCUtil::isTouchInside(textLabel, pTouches)) {
						if (textLabel->getTag() == m_pTouchedDotSprite->getTag()) {
							// dotArray에 이미지 부분부터 추가되므로 뒤에서부터 탐색
							for (int i=m_pDotSprites->count()-1; i>=0; i--) {
								CCSprite *dotSprite = (CCSprite *)m_pDotSprites->objectAtIndex(i);
								if (dotSprite->getTag() == textLabel->getTag()) {
									matchedDotSprite = dotSprite;
									break;
								}
							}
						}else {
							isTouchedIncorrectly = true;
						}
						
						break;
					}
				}
			}
			else {
				// 뒤쪽에 있는 것은 text부분에 있는 점 => image 부분 터치 체크
				for (int i=0; i<m_pImageArray->count(); i++) {
					CCSprite *imageSprite = (CCSprite *)m_pImageArray->objectAtIndex(i);
					if (LCUtil::isTouchInside(imageSprite, pTouches)) {
						if (imageSprite->getTag() == m_pTouchedDotSprite->getTag()) {
							// dotArray에 이미지 부분부터 추가되므로
							for (int i=0; i<m_pDotSprites->count(); i++) {
								CCSprite *dotSprite = (CCSprite *)m_pDotSprites->objectAtIndex(i);
								if (dotSprite->getTag() == imageSprite->getTag()) {
									matchedDotSprite = dotSprite;
									break;
								}
							}
						}else {
							isTouchedIncorrectly = true;
						}
					}
				}
			}
		}
		
		// 올바르게 터치된 점이 있다면
		if (matchedDotSprite) {
			m_pFinishedDotSprites->addObject(m_pTouchedDotSprite);
			m_pFinishedDotSprites->addObject(matchedDotSprite);
			m_pDotSprites->removeObject(m_pTouchedDotSprite);
			m_pDotSprites->removeObject(matchedDotSprite);
			
			// 터치된 스프라이트 찾기
			CCSprite* matchedSprite = NULL;
			for (int i=0; i<m_pImageArray->count(); i++) {
				CCSprite* sprite = (CCSprite*)m_pImageArray->objectAtIndex(i);
				if (sprite->getTag() == matchedDotSprite->getTag()) {
					matchedSprite = sprite;
					break;
				}
			}
			
			this->didMatchWord();
			this->didMatchWord(matchedSprite, m_pIndexArray, matchedDotSprite->getTag());
			drawMatchedLines();
			
			if (m_pDotSprites->count() == 0) {
				//CCLog("finished");
				this->didFinishedStage();
				//load
				CCSequence* seq = CCSequence::actions(CCDelayTime::actionWithDuration(this->delayTimeOfChangeWord(m_pIndexArray, m_iIndex)),
													  CCCallFunc::actionWithTarget(this, callfunc_selector(LCCrossMatchGame::didDelayedChangeWord)) ,NULL);
				this->runAction(seq);
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


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