Exemplo n.º 1
0
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("----------------------------------");
}
Exemplo n.º 3
0
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));
}
Exemplo n.º 4
0
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);
}
Exemplo n.º 5
0
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("----------------------------------");
}
Exemplo n.º 6
0
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);
}
Exemplo n.º 7
0
bool HSBalloonSprite::ContainsTouchLocation( CCTouch* touch )
{
	if(!touch || !m_isTouchEnabled)
	{
		return false;
	}

	//return TextureRect().containsPoint(touch->getLocation());
	return TextureRect().containsPoint(convertTouchToNodeSpaceAR(touch));
}
Exemplo n.º 8
0
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();
		}
}
Exemplo n.º 10
0
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("----------------------------------");

    
}
Exemplo n.º 11
0
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触摸不被吞掉
}
Exemplo n.º 12
0
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´¥Ãþ²»±»Í̵ô
}
Exemplo n.º 13
0
bool CursorTextField::isInTextField(cocos2d::CCTouch *pTouch)
{
    return getRect().containsPoint(convertTouchToNodeSpaceAR(pTouch));
}
Exemplo n.º 14
0
bool CDragSprite::IsTouchInSprite(CCTouch* pkTouch)
{
	return CCRect::CCRectContainsPoint(GetTouchRect(),
		convertTouchToNodeSpaceAR(pkTouch));
}
Exemplo n.º 15
0
    bool containsTouchLocation(CCTouch* touch)
    {
	    return rect().containsPoint(convertTouchToNodeSpaceAR(touch));
    }
Exemplo n.º 16
0
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;
}
Exemplo n.º 17
0
bool CActionButton::containsTouchLocation( CCTouch* touch )
{
	return GetRect().containsPoint(convertTouchToNodeSpaceAR(touch));
}
Exemplo n.º 18
0
bool Paddle::containsTouchLocation(CCTouch* touch)
{
	return CGRect::CGRectContainsPoint(rect(), convertTouchToNodeSpaceAR(touch));
}
Exemplo n.º 19
0
bool GameObjHero::containsTouchLocation(Touch* touch)
{
    //return CCRect::CCRectContainsPoint(rect(), convertTouchToNodeSpaceAR(touch));
	return rect().containsPoint(convertTouchToNodeSpaceAR(touch));
}
Exemplo n.º 20
0
bool CSSprite::containsTouchLocation(CCTouch* touch)
{
	return CCRect::CCRectContainsPoint(rect(), convertTouchToNodeSpaceAR(touch));
}
Exemplo n.º 21
0
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));
}
Exemplo n.º 22
0
bool FramePart::containsTouchLocation(Touch* touch)
{
    return getRect().containsPoint(convertTouchToNodeSpaceAR(touch));
}
Exemplo n.º 23
0
bool Paddle::containsTouchLocation(CCTouch* touch)
{
	CCPoint ccp = convertTouchToNodeSpaceAR(touch);
	return rect().containsPoint(ccp);
}
Exemplo n.º 24
0
bool GameObjHero::containsTouchLocation(CCTouch* touch)
{
    CCRect r = rect();
    return r.containsPoint(convertTouchToNodeSpaceAR(touch));
}
Exemplo n.º 25
0
bool TouchableSprite::containsTouchLocation(CCTouch* touch) {
  CCPoint pos = convertTouchToNodeSpaceAR(touch);
  return rect().containsPoint(pos);
}
Exemplo n.º 26
0
/////////////////////////////////////////////////////////
// Lay pham vi cua phan tu touch
/////////////////////////////////////////////////////////
bool ColorButton::containsTouchLocation(Touch* touch)
{
    return getRect().containsPoint(convertTouchToNodeSpaceAR(touch));
}
Exemplo n.º 27
0
bool ScrollView::containsTouchLocation(CCTouch* touch)
{
	CCSize s = getContentSize();
	CCRect rect = CCRectMake(0, 0, s.width, s.height);
	return rect.containsPoint(convertTouchToNodeSpaceAR(touch));
}