SpriteKit iPhone/iPad different resolution, need same physics - ios

As I am porting an iPhone app that uses SpriteKit to iPad, I have been able to scale all the screen elements and font sizes using the height ratio of the iPhone 5 to iPad screen.
Everything looks proportional, except for the physics since there is more area.
So the question is, how do I scale the physics along with the screen using that height ratio?
Perhaps changing density or mass of all the nodes? How would I do it, mathematically using the ratio so that it is perfect?

You can configure the SKPhysicsWorld object attached to the SKScene.
It changes:
The gravity property that applies an acceleration to volume-based bodies in the simulation.
The speed property determines the rate at which the simulation runs.
You can set those properties to values that seems good to you on an iPad. Changing the Physic World changes physics for all SKObjects.

Related

How to map SceneKit sizes to artwork pixel sizes?

Related to this question about creating static scenes in SceneKit, how are you supposed to map node sizes to artwork size?
Let's say you have a SCNSphere with a radius of 1. And inside the sphere you want to present a character sprite.
How do you decide how large the sprite artwork should be, that is, what is the relationship between the artwork pixel size and the SCNNode size?
For SpriteKit, this is done automatically as the nodes assume the size of the sprite textures by default.
Right now, the only solution seems to be a trial-and-error process where you try different sized artwork until one "fits" properly (i.e., not too small, not too big) inside the sphere, but surely there must be a more elegant approach?

How does sceneKit deal with various screen sizes?

How does sceneKit deal with various screen sizes? Do geometries become bigger on larger screens? Does camera angle become bigger and wider? Do physics simulations look exactly the same on various phones? Thanks for help.
Do geometries become bigger on larger screens?
Nope, geometry size will be the same size, in the arbitrary unit you use (Meters by default). They will however appear bigger/smaller on screen but the size is the same (see next answer).
Does camera angle become bigger and wider?
Slightly. The FOV adapts on an axis to fit the aspect of the screen. You can try that out by running your app on the resizable simulator and see how it reacts.
Do physics simulations look exactly the same on various phones?
Yes and no. Overall, the simulation will feel the same (weight, speed, behaviour), but in details the randomness of the physics engine and the differences in hardware will make the simulations slightly different and random every time.

Understanding how Xcode works with vector files

I have a game that is extremely procedural and because of this one of the textures in the games can end up covering the space of (113 x 10) to (682 x 768) on iPad retina. Furthermore it isn't always even in the same aspect ratio. Furthermore the unscaled texture has to be at an aspect ratio of about 2:11 making things awkward.
I can not figure out how Xcode perceives pdf vector files.
For example the first time I made my svg into a pdf and followed all the instructions for making a single vector slot it ended up being all pixelated/anti-aliased on some devices. And I know that .pdf vectors can be rasterized to any resolution without loosing quality! So I am pretty sure Xcode compiles vectors into bitmaps for the SKTexture. And as far as I can tell the amount of pixels that it rasterizes from the vector is not even variable on a device.
For example after that one I scaled up the svg to double the pts of its dimensions and exported it. Now on some devices the texture looked perfect yet on others it looked like a rasterized mess! And it didn't seem to happen because of one device resolution being bigger then the other.
So then I decided to scale the vector one more time so at this point it had 4x more points then the vector started as. Things worked wonderfully, until I tested on the iPhone 6 and instead of being beautiful the texture got blacked out, I am fairly certain this is because the texture was to big for Spritekit. There is no happy medium I can find.
My goal is to get this vector file looking great on every device regardless of how it is scaled.
I have looked around to see what SpriteKit uses for its pt to pixel conversions and I haven't found any numbers that check out. How I can make my texture work for this project? How does Spritekit decide how many pixels to rasterize a vector as when I make an SKTexture.
Edit:
Here are some hypothetical questions.
H1. How many points wide and tall would a pdf vector need to be for it to be able to be up to these dimensions on any device. width = width of device, height = height of device / 2. So basically if I had a vector I knew was going to occupy that space what should its dimensions (in points) be?
H2. Is the amount of pixels rasterized for every point directly proportionate to the amount of pixels on the display or is their more then just pixels on a screen?

Impulse on different screen sizes Spritekit Xcode

Hi I'm making a game where you tap to give an upward impulse to the ball of lets for example say a cgvector (4,0).
This if for both 4inch and 3.5 inch retina displays.
Will the impulse move the ball the same amount in pixels or same amount relative to the screen size different. I need the ball to move the same amount relative to the size or else the game will become easier on i5's . I have an idea of how to achieve it.
Could someone with knowledge of how impulse works clear this up?
Only asking because i recently played it on a i5 and got higher scores than usually on the i4
Thanks
physics simulation does not depend on screen size, however the scene may be scaled (see scaleMode) which can affect how much of the scene you can see on each device.

corona physics - different mass object?

this is what i'm trying to do, 2 balls will drop at different height, their bounce is set to 1.0, which means after bounce they will go back to their original position. But the higher ball will drop and bounce faster than the lower ball, so when the higher ball bounces and goes back to it's original position once, the lower ball finishes its first bounce too.
is ok that they don't bounce once at the same time? i just want to know how i can change their speed.
so far what i have found is that we can't change their mass, density won't effect drop speed, set gravity will effect both. any solution please?
and i'm trying to change the mass of those ball, so the ball that higher from the ground can drop faster
Heavier things do not fall faster. Either in reality or a proper simulation thereof. The reason why we think of heavy things falling faster is because of air resistance. Objects moving through the air have resistance from that air, and this slows down light objects more than heavier ones.
So you would either have to break the physics system or implement air resistance.

Resources