bool MySprite::containsTouchLocation(CCTouch *touch) { //CCPoint pos = touch->getLocationInView(); CCPoint pos = convertTouchToNodeSpaceAR(touch); //return CCRect::CCRectContainsPoint(rect(), pos); return rect().containsPoint(pos); }
void KeyboardNotificationLayer::onTouchEnded(Touch *touch, Event *event) { if (! _trackNode) { return; } auto endPos = touch->getLocation(); float delta = 5.0f; if (kdFabsf(endPos.x - _beginPos.x) > delta || kdFabsf(endPos.y - _beginPos.y) > delta) { // not click _beginPos.x = _beginPos.y = -1; return; } // decide the trackNode is clicked. Rect rect; auto point = convertTouchToNodeSpaceAR(touch); CCLOG("KeyboardNotificationLayer:clickedAt(%f,%f)", point.x, point.y); rect = getRect(_trackNode); CCLOG("KeyboardNotificationLayer:TrackNode at(origin:%f,%f, size:%f,%f)", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); this->onClickTrackNode(rect.containsPoint(point)); CCLOG("----------------------------------"); }
bool PlayerSprite::containsTouchLocation(CCTouch* touch) { CCSize size = getContentSize(); CCRect rect = CCRect(-size.width/2, -size.height/2, size.width, size.height); return rect.containsPoint(convertTouchToNodeSpaceAR(touch)); }
bool BaseBug::containsTouchLocation(cocos2d::CCTouch * pTouch){ CC_ASSERT(m_bug); CCSize s = m_bug->getContentSize(); CCRect rect = CCRectMake(-s.width/2, -s.height/2, s.width, s.height); CCPoint nodePoint = convertTouchToNodeSpaceAR(pTouch); return rect.containsPoint(nodePoint); }
void KeyboardNotificationLayer::ccTouchended(CCTouch *pTouch, CCEvent *pEvent) { if (! m_pTrackNode) { return; } CCPoint endPos = pTouch->getLocation(); float delta = 5.0f; if (::abs(endPos.x - m_beginPos.x) > delta || ::abs(endPos.y - m_beginPos.y) > delta) { // not click m_beginPos.x = m_beginPos.y = -1; return; } // decide the trackNode is clicked. CCRect rect; CCPoint point = convertTouchToNodeSpaceAR(pTouch); CCLOG("KeyboardNotificationLayer:clickedAt(%f,%f)", point.x, point.y); rect = getRect(m_pTrackNode); CCLOG("KeyboardNotificationLayer:TrackNode at(origin:%f,%f, size:%f,%f)", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); this->onClickTrackNode(rect.containsPoint(point)); CCLOG("----------------------------------"); }
bool BaseSprite::_isContainPoint( CCTouch *touch ) { CCPoint arPoint = getAnchorPointInPoints(); CCPoint point = convertTouchToNodeSpaceAR(touch); CCRect rect = boundingBox(); CCSize spriteSize = rect.size; CCRect spriteRect = CCRectMake(-arPoint.x,-arPoint.y,spriteSize.width,spriteSize.height); return spriteRect.containsPoint(point); }
bool HSBalloonSprite::ContainsTouchLocation( CCTouch* touch ) { if(!touch || !m_isTouchEnabled) { return false; } //return TextureRect().containsPoint(touch->getLocation()); return TextureRect().containsPoint(convertTouchToNodeSpaceAR(touch)); }
bool IPadSprite::ccTouchBegan(CCTouch* touch, CCEvent* event) { if(!(this->getIsVisible())) return false; CCSize s = this->getContentSize(); CCRect rc = CCRectMake(-s.width / 2, 0, s.width, s.height/2); if(!CCRect::CCRectContainsPoint(rc, convertTouchToNodeSpaceAR(touch))) return false; return true; }
void KeyboardNotificationLayer::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent) { //if no node was watching, return, no handle anymore. int count = this->nodeArray->count(); if (count == 0) { return; } // decide the trackNode is clicked. CCRect rect; CCPoint point = convertTouchToNodeSpaceAR(pTouch); //loop InputElement inside, decide to call which InputElement* preFocus = this->current; InputElement *nowFocus = NULL; for (int i = 0; i < count; i++) { InputElement *input = (InputElement*)this->nodeArray->objectAtIndex(i); CCRect rect = input->GetRangeRect(); if (rect.containsPoint(point)) { nowFocus = input; break; } } this->current = nowFocus; //if select on the same object, do nothing if (nowFocus == preFocus) { return; } //leave pre input if (preFocus != NULL) { preFocus->OnLeave(); } //enter new select input if (nowFocus != NULL) { nowFocus->OnEnter(); } }
void LoginView::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent) { CCLog("LoginView::ccTouchEnded +++++++++++++++++++++++++++++++++"); if (! mTrackNodeArray) { CCLog("track node is null +++++++++++"); return; } CCPoint endPos = pTouch->locationInView(); // 触摸结束的时候,手指所在坐标 endPos = CCDirector::sharedDirector()->convertToGL(endPos); float delta = 5.0f; if (::abs(endPos.x - this->mBeginPos.x) > delta || ::abs(endPos.y - this->mBeginPos.y) > delta) { // not click mBeginPos.x = this->mBeginPos.y = -1; return; } // 处理被点击(decide the trackNode is clicked.) CCTextFieldTTF* trackNode = NULL ; CCRect rect; CCPoint point = convertTouchToNodeSpaceAR(pTouch); CCLog("LoginView:clickedAt(%f, %f)", point.x, point.y); for(int i=0; i<this->mTrackNodeArray->count(); i++) { CCLog("track index is: %d", i) ; trackNode = (CCTextFieldTTF*) this->mTrackNodeArray->objectAtIndex(i) ; rect = getRect(trackNode); // 得到节点的矩形框 CCLog("LoginView:TrackNode at(origin:%f,%f, size:%f,%f)", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); // 处理跟踪节点 this->onClickTrackNode(trackNode, CCRect::CCRectContainsPoint(rect, point)); } CCLog("----------------------------------"); }
bool Poker::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent){ CCSize size = getContentSize(); CCRect rect(-size.width/2,-size.height/2,size.width,size.height); CCPoint ptouch = convertTouchToNodeSpaceAR(pTouch); //由英文之意转换 触摸 到 节点空间 if(rect.containsPoint(ptouch) && m_isDianJi) { if(!m_isSelect){ SelectPkLuTou(); } else{ SelectPkSuoTou(); } return true; } return false; //如果这里返回false触摸不被吞掉 }
bool Poker::onTouchBegan(CCTouch *pTouch, CCEvent *pEvent){ CCSize size = getContentSize(); CCRect rect(-size.width/2,-size.height/2,size.width,size.height); CCPoint ptouch = convertTouchToNodeSpaceAR(pTouch); //ÓÉÓ¢ÎÄÖ®Òâת»» ´¥Ãþ µ½ ½Úµã¿Õ¼ä if(rect.containsPoint(ptouch) && m_isDianJi) { if(!m_isSelect){ SelectPkLuTou(); } else{ SelectPkSuoTou(); } return true; } return false; //Èç¹ûÕâÀï·µ»Øfalse´¥Ãþ²»±»Í̵ô }
bool CursorTextField::isInTextField(cocos2d::CCTouch *pTouch) { return getRect().containsPoint(convertTouchToNodeSpaceAR(pTouch)); }
bool CDragSprite::IsTouchInSprite(CCTouch* pkTouch) { return CCRect::CCRectContainsPoint(GetTouchRect(), convertTouchToNodeSpaceAR(pkTouch)); }
bool containsTouchLocation(CCTouch* touch) { return rect().containsPoint(convertTouchToNodeSpaceAR(touch)); }
bool Screen::containsTouchLocation(CCTouch* touch) { return CCRectMake(-Options::CAMERA_WIDTH / 2, -Options::CAMERA_HEIGHT / 2, Options::CAMERA_WIDTH, Options::CAMERA_HEIGHT).containsPoint(convertTouchToNodeSpaceAR(touch)); // TODO: I should check this instructions; }
bool CActionButton::containsTouchLocation( CCTouch* touch ) { return GetRect().containsPoint(convertTouchToNodeSpaceAR(touch)); }
bool Paddle::containsTouchLocation(CCTouch* touch) { return CGRect::CGRectContainsPoint(rect(), convertTouchToNodeSpaceAR(touch)); }
bool GameObjHero::containsTouchLocation(Touch* touch) { //return CCRect::CCRectContainsPoint(rect(), convertTouchToNodeSpaceAR(touch)); return rect().containsPoint(convertTouchToNodeSpaceAR(touch)); }
bool CSSprite::containsTouchLocation(CCTouch* touch) { return CCRect::CCRectContainsPoint(rect(), convertTouchToNodeSpaceAR(touch)); }
bool HSCCSprite::ContainsTouchLocation( CCTouch* touch ) { CCSize s = getTexture()->getContentSize(); CCRect r = CCRectMake(-s.width / 2, -s.height / 2, s.width, s.height); return r.containsPoint(convertTouchToNodeSpaceAR(touch)); }
bool FramePart::containsTouchLocation(Touch* touch) { return getRect().containsPoint(convertTouchToNodeSpaceAR(touch)); }
bool Paddle::containsTouchLocation(CCTouch* touch) { CCPoint ccp = convertTouchToNodeSpaceAR(touch); return rect().containsPoint(ccp); }
bool GameObjHero::containsTouchLocation(CCTouch* touch) { CCRect r = rect(); return r.containsPoint(convertTouchToNodeSpaceAR(touch)); }
bool TouchableSprite::containsTouchLocation(CCTouch* touch) { CCPoint pos = convertTouchToNodeSpaceAR(touch); return rect().containsPoint(pos); }
///////////////////////////////////////////////////////// // Lay pham vi cua phan tu touch ///////////////////////////////////////////////////////// bool ColorButton::containsTouchLocation(Touch* touch) { return getRect().containsPoint(convertTouchToNodeSpaceAR(touch)); }
bool ScrollView::containsTouchLocation(CCTouch* touch) { CCSize s = getContentSize(); CCRect rect = CCRectMake(0, 0, s.width, s.height); return rect.containsPoint(convertTouchToNodeSpaceAR(touch)); }