6

I have ball that is bouncing around the scree, something like pong.
Radius of ball depend on the with of screen.

I have found that ball is not going with same speed on iPhone and iPad.
Because ball is bigger on iPad, so it has bigger ball.physicsBody.mass.

Question How to properly fix this ?
I have found two way:
First is: SpriteKit iPhone/iPad different resolution, need same physics to change SKPhysicsWorld. Second is: SpriteKit ball speed differ on size to fix mass of ball.

I think that fixing the massof ball is proper way.
Am I correct ?

Community
  • 1
  • 1
WebOrCode
  • 6,852
  • 9
  • 43
  • 70
  • 1
    Why not do a quick test? Increase mass relative to the size difference of the circle shape, see if it behaves the same on both devices. I don't think it will though because there may not be a linear relation to mass and shape size. Even then you would have to scale up the mass for all other bodies too, as well as gravity, in order to ensure at least similar collision behavior. – CodeSmile Jul 22 '14 at 08:48
  • I have done those test and on SpriteKit and what I can say for sure is that speed depend on mass linearly, but I have not seen liner relation between size/area/volume and mass. This look to me as very common problem. If you make game like pong, you want same movement of ball on all devices. So I was hoping that somebody, who have solved it, can give some experience how he solved it. – WebOrCode Jul 22 '14 at 09:12
  • My previous comment is wrong, because I did calculations on calc and did some rounding. After putting everything in excel (and doing CORREL function) I can say that everything is liner e.g. mass to shape size. – WebOrCode Jul 22 '14 at 09:30
  • So in the end which way did you go with and how did you do it? Because none of this is working for me. – datWooWoo Feb 25 '15 at 22:18

1 Answers1

0

App in which I have used this approach can been seen at:
https://itunes.apple.com/us/app/pongfinity/id930801337

I have done following:

I have fixed: friction, restitution, linearDamping, and mass, all properties on ball physicsBody.

I used function written by myself:

NSUInteger normalizeForHeight(NSUInteger number)
{
    CGRect  screenRect   = [[UIScreen mainScreen] bounds];
    CGFloat screenHeight = screenRect.size.height;



    CGFloat factor = 1.0;
    factor = screenHeight / 480;
    return (number * factor);
}

So every time when I am changing speed of the ball, I am using this normalizeForHeight(20) , 20 is just some constant I I picked.

WebOrCode
  • 6,852
  • 9
  • 43
  • 70