Ipad 在滑动过程中TileMap中的移动滞后
我正在开发一个具有等距瓷砖贴图(44x44大小)的游戏。我在iPad-1上滑动地图时遇到麻烦,但在iPad-2上运行良好。即使只有没有精灵的贴图,移动贴图也是不平滑的 我使用easeout动作来提供延迟运动:Ipad 在滑动过程中TileMap中的移动滞后,ipad,cocos2d-x,Ipad,Cocos2d X,我正在开发一个具有等距瓷砖贴图(44x44大小)的游戏。我在iPad-1上滑动地图时遇到麻烦,但在iPad-2上运行良好。即使只有没有精灵的贴图,移动贴图也是不平滑的 我使用easeout动作来提供延迟运动: _tileMap->runAction(CCEaseOut::create(CCMoveTo::create(time, bottomLeft),2)) 或 我尝试了2d投影并关闭了亚像素渲染(在ccConfig.h中)。但这个问题仍然存在 我的滑动处理程序函数如下 void
_tileMap->runAction(CCEaseOut::create(CCMoveTo::create(time, bottomLeft),2))
或
我尝试了2d投影并关闭了亚像素渲染(在ccConfig.h中)。但这个问题仍然存在
我的滑动处理程序函数如下
void GameController::SwipeHander(CCPoint vector,float speed)
{
CCPoint change=ccpMult(vector, speed/(1000)); //it is a wh
CCPoint bottomLeft =ccpSub(_tileMap->getPosition(), change); //point where map gonna move
// just to check bottomleft comes in bounding box
if (bottomLeft.x >0) {
bottomLeft.x = 0;
}
if (bottomLeft.y>0) {
bottomLeft.y = 0;
}
if (bottomLeft.x < -(mapWidth*_tileMap->getScale() - _screenSize.width)) {
bottomLeft.x = -(mapWidth*_tileMap->getScale()- _screenSize.width);
}
if (bottomLeft.y <-(mapHieght*_tileMap->getScale() - _screenSize.height)) {
bottomLeft.y = - (mapHieght*_tileMap->getScale() - _screenSize.height);
}
float dis=_tileMap->getPosition().getDistance(bottomLeft);
float time=(dis/speed);
_tileMap->stopAllActions();
_tileMap->runAction(CCEaseOut::create(CCMoveTo::create(time, bottomLeft),1.5));
}
void GameController::SwipeHander(C点向量,浮点速度)
{
CCPoint change=ccpMult(向量,速度/(1000));//它是一个wh
CCPoint bottomLeft=ccpSub(_tileMap->getPosition(),change);//地图要移动的点
//只需选中bottomleft在边界框中
如果(左下角.x>0){
左下角x=0;
}
如果(左下角y>0){
左下角y=0;
}
if(bottomLeft.x<-(mapWidth*\u tileMap->getScale()-\u screenSize.width)){
bottomLeft.x=-(mapWidth*\u tileMap->getScale()-\u screenSize.width);
}
if(左下角.y getScale()-_screenSize.height)){
左下角.y=-(Maphight*_tileMap->getScale()-_screenSize.height);
}
float dis=\u tileMap->getPosition().getDistance(左下角);
浮动时间=(dis/速度);
_tileMap->stopAllActions();
_tileMap->runAction(CCEaseOut::create(CCMoveTo::create(time,左下角),1.5));
}
如果这两种实现之间的唯一区别是您运行的硬件,那么这听起来像是一个处理瓶颈。也就是说,你要求iPad-1满足一个处理时间线,但鉴于其内部的硬件,它无法满足
您似乎不太可能修改框架以显著提高其性能……除非您编写了自己的自定义实现。这是可能的,但是你有多少时间?此外,这也是你使用框架而不是编写框架的原因
除非了解到iPad-1相对于iPad-2的性能有所提高(即框架中的某些东西实际上不同但可以修复),否则在iPad-1上运行时,最好的选择似乎是采取某种性能降低措施
选项:
我在iPad1上也面临着同样的问题,我的老板也不同意“跳转”。因此,不用easeout,你只需在没有延迟运动的情况下使滑动工作即可。
但是,如果完美是你呼吸的氧气,我建议使用回调函数,在每次迭代中减少速度向量的某个因子。这应该行得通我正在测试在一个图层上只使用tileMap进行滑动,没有其他处理(没有其他处理)和低分辨率图像,但仍然滞后。我知道iPad可以处理这个问题。在未来,我将向它添加数百个精灵,但我不知道我将要做什么。你检查了Cocos2d-x的帧速率设置了吗?我不能说硬件的差异,但如果这是造成它的原因,你最好的选择,在下降这么多的情况下,是做类似选项3的事情:如果你能以其他方式获得效果,不要做运动(即,只需跳转屏幕而不是使用动画)。
void GameController::SwipeHander(CCPoint vector,float speed)
{
CCPoint change=ccpMult(vector, speed/(1000)); //it is a wh
CCPoint bottomLeft =ccpSub(_tileMap->getPosition(), change); //point where map gonna move
// just to check bottomleft comes in bounding box
if (bottomLeft.x >0) {
bottomLeft.x = 0;
}
if (bottomLeft.y>0) {
bottomLeft.y = 0;
}
if (bottomLeft.x < -(mapWidth*_tileMap->getScale() - _screenSize.width)) {
bottomLeft.x = -(mapWidth*_tileMap->getScale()- _screenSize.width);
}
if (bottomLeft.y <-(mapHieght*_tileMap->getScale() - _screenSize.height)) {
bottomLeft.y = - (mapHieght*_tileMap->getScale() - _screenSize.height);
}
float dis=_tileMap->getPosition().getDistance(bottomLeft);
float time=(dis/speed);
_tileMap->stopAllActions();
_tileMap->runAction(CCEaseOut::create(CCMoveTo::create(time, bottomLeft),1.5));
}