0
votes

I'm writing a top down racing game. A quick anatomy of the game is: The "car node" moved by setting the physicsBody velocity in update method (i wanna set velocity of the physicbody and not the position because i wanna retrive the velocity value of the car object anywhere in the game...), so this is the car movement:

 float dx=JoyPadRelativePosition.x*_maxSpeed;
 float dy=JoyPadRelativePosition.y*_maxSpeed;
 [self.car.physicsBody setVelocity: CGVectorMake(dx,-dy)];

At the same time in didSimulatePhysics i move the _worldNode to leave the car always in the center of the screen:

CGPoint target = [self pointToCenterViewOn:self.car.position];
CGPoint newPosition = _worldNode.position;
newPosition.x += (target.x - _worldNode.position.x);
newPosition.y += (target.y - _worldNode.position.y);
SKAction *actionMove = [SKAction moveTo:newPosition duration:0.4];
[_worldNode runAction:actionMove];

With this code the movement of the background and the movement of the car works correctly and smoothly in Ipad2 and iphone5 at 60 fps. The problem comes with iphone4, with this device the background jitter and global fps decreses to 40 fps. Reading stackOverflow questions and some blogs i have found a solution, limit the global fps to 30 (in this way i can be sure that all device will run at the same rate).

_skView.frameInterval=2;

With this setting anyway my background jitters in Ipad2,iphone5 and Iphone 4 (all real devices). Why? I have to modify something in my code due the new standard 30 fps rate?

1
it probably "jitters" because 30 fps isn't as smooth as 60 fps, which is a lot more noticeable in games compared to movies running at 24 fps - LearnCocos2D
so there's no way to make it smoother at 30 fps? - user31929
no, by definition a 30 frames per second animation will draw the screen contents less often, thus it won't look as smooth as 60 fps - LearnCocos2D

1 Answers

0
votes

Since you're using a physics simulation have you considered slowing down the speed for iPhone4? You can set the speed of the physics simulation to 0.5 instead of the default of 1 and see if that helps with the jitter. Look at the speed method of SKPhysicsWorld.