本文整理汇总了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();
}
}
}
示例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(); //开始减速
}
}
}