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));
}
}
这里解决了屏幕闪的问题,想想为什么呢?
阅读(1776) | 评论(0) | 转发(0) |