I'm developing a simple ball game in Sprite Kit. I need to predict the ball's trajectory, so I went back to my physics book for the equations for acceleration, time, speed and space.
The problem is that Sprite Kit documentation does not declare the units of measurement of the properties of physics bodies, so it's hard to calculate the needed values.
Based on my experiments/research I suppose that:
- gravity is expressed in m/s/s (m/s^2)
- since gravity is a CGVector, all CGVectors are expressed in m/s/s (m/s^2)
- velocity (instant speed) is m/s
Then I realized a simple scene where a ball is falling:
- Gravity: CGVector(0,1.2);
- Height: 218.009499 pixels
- Time: 0.302499747
- Then acceleration should be: 2*Height / Time^2 = 1441.3863 pixels/s/s
- And gravity of 1.2m/s/s corresponds to 1441.3863 in a world measured in pixels
Someone says the internal PTM (pixel to meter ratio) is 150.