Ipad 在滑动过程中TileMap中的移动滞后

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

我正在开发一个具有等距瓷砖贴图(44x44大小)的游戏。我在iPad-1上滑动地图时遇到麻烦,但在iPad-2上运行良好。即使只有没有精灵的贴图,移动贴图也是不平滑的

我使用easeout动作来提供延迟运动:

_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上运行时,最好的选择似乎是采取某种性能降低措施

选项:

  • 默认情况下,帧速率设置为60 fps。你应该能以每秒30帧的速度逃跑。如果设备是iPad-1,请降低帧速率。您还可以仅在关键时刻降低帧速率(例如,该动作降低帧速率,执行效果,然后在完成时增加帧速率)
  • 不同的接口。与iPad-2(或其他)系统相比,在iPad-1上使用较低分辨率的图形
  • 在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));
    
    }