voidBattleView::ccTouchesBegan(CCSet *pTouches,CCEvent *pEvent)
{
//CCSet的迭代器
CCSetIterator iter = pTouches->begin();
//迭代出pTouches所有Touches
for (;iter!= pTouches->end();iter++)
{
//取出Touches
CCTouch* pTouch = (CCTouch*)(*iter);
//得到取出的Touch的位置坐标
CCPoint location = pTouch->getLocation();
//保存第一个点坐标
if (pTouch->getID()==0)
{
m_Point1 = location;
initialD = true;
}
//第二个点,保存坐标
if (pTouch->getID()==1&& initialD ==true)
{
m_Point2 = location;
m_beganLocation = location;
}
}
}
voidBattleView::ccTouchesMoved(CCSet *pTouches,CCEvent *pEvent)
{
CCSetIterator iter = pTouches->begin();
for (;iter!=pTouches->end();iter++)
{
CCTouch* pTouch = (CCTouch*)(*iter);
//得到触摸点的坐标
CCPoint location = pTouch->getLocation();
if (pTouch->getID()==0)
{
movePoint1 = location;
}
if (pTouch->getID()==1)
{
movePoint2 = location;
m_endLocation = location;
CCPoint moveTo=ccpSub(m_endLocation, m_beganLocation);
m_beganLocation=m_endLocation;
m_BattleWorld->setPosition(ccpAdd(m_BattleWorld->getPosition(), moveTo));
}
}
这里解决了屏幕闪的问题,想想为什么呢?
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。