Пример #1
0
void TankJoyStick::onTouchMoved(cocos2d::Touch *touch, cocos2d::Event *event)
{
    auto orilocation = Director::getInstance()->convertToGL((touch->getLocationInView()));
    auto location = convertToNodeSpaceAR(orilocation);
    //CCLOG("move to,oriPos(%f,%f),pos:(%f,%f)",orilocation.x,orilocation.y,location.x,location.y);
    updateVelocity(location);
}
Пример #2
0
//¶ÔÏóÊÇ·ñ±»´¥Ãþ
//bool BaseObject::containsTouchLocation(cocos2d::CCTouch *touch)
bool BaseObject::containsTouchLocation(CCPoint world_point)
{
	CCSize size = getSprite()->getContentSize();
	CCRect rect = CCRect(-size.width / 2.0, -size.height / 2.0, size.width, size.height);
	//return rect.containsPoint(convertTouchToNodeSpaceAR(touch));
	return rect.containsPoint(convertToNodeSpaceAR(world_point));
}
Пример #3
0
void MaskShaderEffect::setMaskPosition(Point &p)
{
	Point q = convertToNodeSpaceAR(p);
	if (abs(q.x) > _resolution.x*0.5 ||
		abs(q.y) > _resolution.y*0.5)
		log("warning: mask position out of contents size!");

	/* We setup the @_touchPoint as the mask position. */
	_touchPoint.x = p.x;
	_touchPoint.y = p.y;
}
Пример #4
0
bool TankJoyStick::onTouchBegin(cocos2d::Touch *touch, cocos2d::Event *event)
{
    auto orilocation = Director::getInstance()->convertToGL(touch->getLocationInView());
    auto location = convertToNodeSpaceAR(orilocation);
    
    if (location.x < -radius || location.x > radius || location.y<-radius || location.y>radius) {
        return  false;
    }
    else
    {
        float dsq = location.x*location.x+location.y*location.y;
        if (dsq<radiusSqr) {
            updateVelocity(location);
        }
    }
    return true;
}
Пример #5
0
void ConvertToNode::onTouchesEnded(const std::vector<Touch*>& touches, Event *event)
{
    for( auto& touch : touches)
    {
        auto location = touch->getLocation();

        for( int i = 0; i < 3; i++)
        {
            auto node = getChildByTag(100+i);
            Vec2 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);
        }
    }    
}
Пример #6
0
bool TouchablePoker::onTouchBegan(Touch *touch, Event *event)
{
    Point touchPoint = touch->getLocation();
    touchPoint = convertToNodeSpaceAR(touchPoint);
    bool b = isTouchPointInside(touchPoint);
    if (b) {
        isSelected = !isSelected;
        setIsSelected(isSelected);
        
        PokerRoomLayer * prl = dynamic_cast<PokerRoomLayer *>(getParent()->getParent());
        if(prl)
        {
            prl->update_show_card();
        }
        
        return true;
    }
    return false;
}