Quantcast
Channel: Cocos Forums - Latest topics
Viewing all articles
Browse latest Browse all 17070

How to Fix sprite jittering without using physics?

$
0
0

@Dinamix wrote:

Hello everyone, I ran into a problem with sprite being inconsistent movement when the framerate is changing (even the slightest difference gives it). At the moment I am using the simplified sprite movement in update(float dt) function:

void update(float dt){
    Vec2 oldPos = _player->getPostion();
    // _levelSpeed is a double variable, example : 300
     oldPos.x += _levelSpeed * dt;
    _player->setPostion(oldPos);
}

The main issue, is that the sprite momvement is always jumping back and forward, due to render time is always different (nor always constant 60 fps, or in my slow phone 45-50 fps). I saw the solution for Physics engine (Chimpunk), however I prefer for using a simplified 2d pixel checks. How you guys solved your problem or what's the best aproach to solve this issue (what kind interpolation example/article you used)?
EDIT: Forgot to mention that I am suing Follow action for _Player sprite (planning to use multiple cameras for HUD/parallax node/player).
Thank you.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 17070

Trending Articles