I am new to SpriteKit and Swift, only developed one little Swift App for iOS a month ago. I want to learn more, so here I am doing a little 2D game in Swift / SpriteKit. This is a collection of little questions I have which I did not find any answers to after searching a bit.
1. If I set a scene in the editor to 1024x768, how can I then adapt that size to the user's screen size? There is no option in the editor to simply say "width: 100%, height:100%", like in HTML. Let's say I am setting up my scene in 1024x768, decorating stuff and placing my SKSpriteNodes, some of the enviroment is 16x16, some is 128x128. I guess i need to somehow then fit the scene on each users device in my code resulting in downscaled or upscaled images, right? What's the best practice here? How to? I want something easy like:
scene.scaleSizeTo(userScreen.size)
2. If i put a SKSpriteNode in the Scene Editor, I can then alter it's physics. I simply want the Sprite to work as environment in the scene, which a player can not cross => can contact / collide with. I used only "pinned" and dechecked "dynamic", "allows Rotation" and "affected by gravity", since i want it to simply stay there and "block" space. Then i gave it a category bit mask like "1000" and a contact bit mask like "10", because my bitmask enum looks like that:
static let enemy: UInt32 = 0b00000000000000000000000000000001
static let bullet: UInt32 = 0b00000000000000000000000000000010
static let hero: UInt32 = 0b00000000000000000000000000000100
static let environment: UInt32 = 0b00000000000000000000000000001000
static let powerup: UInt32 = 0b00000000000000000000000000010000
static let enemyBullet: UInt32 = 0b00000000000000000000000000100000
However my hero can still cross the environment block AND there is no SKPhysicsContact thrown. What am i doing wrong here?
3. How do I "fly" through my level as a player? I managed to get the acceleration to work and move the ship on screen to different positions, but i don't know how to let the level "flow". The level should simply scroll as the player plays so that the player will at some point reach the end (assuming my scene is like 10000y high).
I will update this thread, if I have more questions. I hope this forum is the correct place to ask this supposedly easy beginner stuff.
Thanks a lot from a beginner in iOS / Swift / SpriteKit. I only have a lot experience in Java / PHP.