0

在这里,我想从上到下移动一些 cocos2D 精灵对象。在屏幕中随机位置生成的精灵 r。有时所有精灵的运动都不稳定..我不能使用 CCMove,因为我想在精灵之间保持相等的距离。

[self schedule: @selector(updateObjects:)];


-(void)updateObjects:(ccTime) dt
{
    //when I print dt, it gives different value..
    //jerk comes when this value s larger than ideal value..


    for(Obstacles *Obs in ObsArray)
    {
        CGPoint pos = Obs.position;
        pos.y -= gameSpeed;
        Obs.position = pos;
    }
}

我怎么解决这个问题。

4

3 回答 3

0

解决了问题 1. 删除了所有 printf 和 cocos2D 日志 2. 为图像加载添加了单独的线程。3. 在高清模式下使用多个 1024x1024 精灵表代替 2048x2048。

于 2012-09-14T19:15:19.537 回答
0

Cocos2d 使用可变时间步长:是自上次调用此调度选择器以来dt的时间,以秒为单位。如果您的对象必须每秒移动的距离(以点为单位),那么您必须将对象位置更改为。gameSpeedgameSpeed * dt

于 2012-09-04T18:49:03.730 回答
0

我有同样的问题,我尝试了很多东西,最后我发现它在 android 设备上会比 ios 设备更抖动。他们渲染的帧速率应该以恒定的时间间隔更新。如果你使用更新方法然后设置恒定增量时间

例如我使用了更新方法

void MyClass::update(float dt) {
    int positioniteration=8;
    int valocityiteration=8;
    world->Step(1/60.0,valocityiteration,positioniteration);//60 FPS }

我还在 appdelegate 中添加了这些行

director->setDepthTest(false);
director->setProjection(Director::Projection::_2D);// MY GAME IS 2D SO USED 2D PROJECTION .. IT HELPED ME

希望这可以帮助。:)

于 2016-10-30T06:49:18.040 回答