void LCWordPuzzleGame::ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent) { if (m_iIndexOfTargetCharacter + 1 > strlen(m_pCurrentWord)) { // ignore if game finished return; } for (int i=0; i<m_pCharacterSprites->count(); i++) { LCWordPuzzleAlphabet* alphabetSprite = (LCWordPuzzleAlphabet*)m_pCharacterSprites->objectAtIndex(i); if (LCUtil::isTouchInside(alphabetSprite, pTouches)) { char touchedCharacter = alphabetSprite->getAlphabet(); char targetCharacter = *(m_pCurrentWord + m_iIndexOfTargetCharacter); if (targetCharacter == touchedCharacter) { // if touched correct character this->didCorrectCharacterSelected(); // deprecated this->didCorrectCharacterSelected(m_pIndexArray, m_iIndex); m_pFinishedCharacterSprites->addObject(alphabetSprite); m_pCharacterSprites->removeObject(alphabetSprite); CCMoveTo *moveToBlock = CCMoveTo::actionWithDuration(0.5, ((CCLabelAtlas *)m_pBlockSprites->objectAtIndex(m_iIndexOfTargetCharacter))->getPosition()); alphabetSprite->runAction(CCSequence::actions(moveToBlock, CCCallFunc::actionWithTarget(this, callfunc_selector(LCWordPuzzleGame::didCorrectCharacterAnimationFinished)), NULL)); m_iIndexOfTargetCharacter++; break; } else { // if touched incorrect character this->didIncorrectCharacterSelected(); // deprecated this->didIncorrectCharacterSelected(m_pIndexArray, m_iIndex); CCMoveTo *moveToBlock = CCMoveTo::actionWithDuration(0.5, ((CCSprite *)m_pBlockSprites->objectAtIndex(m_iIndexOfTargetCharacter))->getPosition()); CCMoveTo *moveToOrigin = CCMoveTo::actionWithDuration(0.5, alphabetSprite->getOriginalPosition()); alphabetSprite->runAction(CCSequence::actions(moveToBlock, CCCallFunc::actionWithTarget(this, callfunc_selector(LCWordPuzzleGame::didIncorrectCharacterMetBlockAnimationFinished)), moveToOrigin, CCCallFunc::actionWithTarget(this, callfunc_selector(LCWordPuzzleGame::didIncorrectCharacterAnimationFinished)), NULL)); } } } //added by YOungJae Kwon // 워드이미지가 터치된걸 체크 if (m_pCurrentWordImage == NULL) return; CCTouch* touch = (CCTouch*)pTouches->anyObject(); if ( CCRect::CCRectContainsPoint(m_pCurrentWordImage->getRect(),m_pCurrentWordImage->getParent()->convertTouchToNodeSpace(touch)) ) { this->didWordImageTouched(m_pCurrentWordImage); } }
void LCWordPuzzleGame::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent) { for (int i=0; i<m_pCharacterSprites->count(); i++) { LCWordPuzzleAlphabet* alphabetSprite = (LCWordPuzzleAlphabet*)m_pCharacterSprites->objectAtIndex(i); if (LCUtil::isTouchInside(alphabetSprite, pTouches)) { CCScaleTo *scaleUp = CCScaleTo::actionWithDuration(0.1f, 1.2f); CCScaleTo *scaleDown = CCScaleTo::actionWithDuration(0.1f, 1.0f); alphabetSprite->runAction(CCSequence::actions(scaleUp,scaleDown,NULL)); } } for (int i=0; i<m_pFinishedCharacterSprites->count(); i++) { LCWordPuzzleAlphabet* alphabetSprite = (LCWordPuzzleAlphabet*)m_pFinishedCharacterSprites->objectAtIndex(i); if (LCUtil::isTouchInside(alphabetSprite, pTouches)) { CCScaleTo *scaleUp = CCScaleTo::actionWithDuration(0.1f, 1.2f); CCScaleTo *scaleDown = CCScaleTo::actionWithDuration(0.1f, 1.0f); alphabetSprite->runAction(CCSequence::actions(scaleUp,scaleDown,NULL)); } } }