碰到一个奇怪的现象 ,CCMoveTo的时候,精灵的运动位置老是不对,后来发现是精灵设置位置有关(setPosition)。CCMoveTo的坐标点是通过 CCTouch的getLocation得到的!请高手指教!
触摸得到的是世界坐标,你得转换成本地坐标
你确定?通过cctouch->getLocation()得到的是世界坐标系?
— Begin quote from ____
引用第3楼小塔于2014-04-08 10:38发表的 回 2楼(孤独の快乐) 的帖子 :
你确定?通过cctouch->getLocation()得到的是世界坐标系? http://www.cocoachina.com/bbs/job.php?action=topost&tid=197064&pid=920779
— End quote
被你问的我都不确定了,刚去试了下,改变了图层的坐标,获取的触摸点坐标还是不变的。
// returns the current touch location in OpenGL coordinates
CCPoint CCTouch::getLocation() const
{
return CCDirector::sharedDirector()->convertToGL(m_point);
}
获取的是OpenGL坐标系,和世界坐标系是一致的
确实是坐标系的问题!