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


C++ Touch::getPreviousLocation方法代码示例

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


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

示例1: onTouchesMoved

void QTELayer::onTouchesMoved(const std::vector<Touch*>& touches, Event *unused_event)
{
    if(!enableFight) return;
    Touch *touch = touches.at(0);
    Vec2 delta = touch->getDelta();
    Vec2 lastPos = touch->getPreviousLocation();
    Vec2 pos = touch->getLocation();
    
    float dx = pos.x - startTouchPosition.x;
    float dy = pos.y - startTouchPosition.y;
    float dist = sqrtf(dx*dx+dy*dy);
    
    
    streak->setPosition(pos);
    //刀的判断
    dist = pos.distanceSquared(startTouchPosition);
    
    if (dist > 50) {
        //hit test monster
        bool hit = qteMonster->hittestPoint(pos);
        if (hit) {
            hitQteMonster();
        }
    }
}
开发者ID:NjAiYo,项目名称:MonsterGame,代码行数:25,代码来源:QTELayer.cpp

示例2: onTouchMoved

//=============================================================
//=============================================================
void CCScrollLayer::onTouchMoved(Touch *pTouch, Event *pEvent)
{
	//CCSize winSize = CCDirector::sharedDirector()->getWinSize();
	//CCSetIterator it = pTouches->begin();
    Touch* touch = pTouch;
	
	Point movePoint = touch->getLocation();
	Point prePoint = touch->getPreviousLocation();
    
    if(!m_containBeginTouchPointFlag)
        return;
    
    float fMoveX = movePoint.x - prePoint.x;
    float fMoveY = movePoint.y - prePoint.y;
    m_2fLastMoveDis = vertex2(fMoveX, fMoveY);
    
    Node* parent = getParent();
    Point localPoint = parent->convertToNodeSpace(movePoint);
    Rect boundRect = boundingBox();
    
    if(boundRect.containsPoint(localPoint))
    {
        float moveX = movePoint.x - prePoint.x;
        float moveY = movePoint.y - prePoint.y;
        
        Point movePoint = Point::ZERO;
        
        if(m_HMoveAbleFlag)    //横竖是否可移动
        {
            if(m_boundsDragOriation.HOriention != DOE_UNKNOWN) //没超出边界时
            {
                moveX *= m_percentOfMoveWhenDragOut;
            }
            movePoint = Point(m_contentLayer->getPosition().x + moveX,m_contentLayer->getPosition().y);
            
        }
        if(m_VMoveAbleFlag)
        {
            if(m_boundsDragOriation.VOriention != DOE_UNKNOWN) //没超出边界时
            {
                moveY *= m_percentOfMoveWhenDragOut;
            }
            movePoint = Point(movePoint.x,m_contentLayer->getPosition().y + moveY);
        }
        
        refreshDragOrientation(movePoint);     //移动时刷新数据
        m_contentLayer->setPosition(movePoint);  
        refreshDotPosition();
        sendSelector(SSTE_TOUCH_MOVE);
                  
    }
    else //手势移动到边界之外  可能不进入
    {
        m_containBeginTouchPointFlag = false;
        if(m_pagingEnable == true)
        {
            nextPageAction(localPoint);
        }
        else
        {
            moveToEndPosition(false,m_contentLayer->getPosition());
            sendSelector(SSTE_TOUCH_END);
           // beginDeclerate();  //开始减速
        }
    }
    
}
开发者ID:bingwan,项目名称:PlaneClasses,代码行数:69,代码来源:CCScrollLayer.cpp


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