Create a container (fixed aspect ratio) for a landscape SpriteKit game, which can be played both on iPhone and iPad - ios

I want to create a landscape iOS game with SpriteKit, which can be played both on iPhone and iPad. Because of the different aspect ratios I thought it would be usefull to have a fixed frame for the actual game. I would like to treat this game area like a separate container. The rest of the visible area should be filled with a ground, where the character is running on, and a ceiling. Depending on the device the ground and the ceiling will be more visible on the iPad and less on the iPhone.
The anchor point for the game as reference for all upcoming nodes should be in the lower left corner of the game area.
In the following picture I tried to draw my thoughts:
Can you tell me, what is the best way to proceed and which features of SpriteKit are worth to take a look at? I have never worked with scaleModes or something else like this before.
Thank you

Related

Best Swift/iOS practice for changing speed/movement of objects based on device or screen size?

My question would be best asked with a simple example:
If I have a game where a ball is near the bottom of the screen, and the goal of the game is to dodge objects scrolling down towards it, I am having trouble figuring out the best method to make the game "fair."
If the game screen is larger, then that player has an advantage because they see the scrolling objects at the top of the screen with more time to move away from it.
I'm wondering...what is the best practice to "scale" the game to where regardless of the size of the screen, the rate at which the scrolling objects move towards the ball, and eventually reach it is exactly the same?
My first instinct is to scale how fast the objects scroll with the size of the frame the game is in. But for some reason that feels clunky to me, or that if I just scale all the objects relative to the size of the screen, that is enough and I'm worrying over something minimal at best.
Anybody ever had a same kind of issue? What is the best means to have a things "behave" the same if the size of the screen/frame plays a key role in your game?
I am open to general Swift and SpriteKit, as I am just in early stages of thinking how to accomplish it.
For SpriteKit, you'll normally design the game, including the sizes and speeds of objects, with some particular logical frame size. That will then get scaled to fill the screen in some appropriate way. How the scaling should be done depends on the game though. Usually you don't want to have different scalings for width and height, so the issue boils down to how to handle different aspect ratios. There are two main possibilities:
Make sure there's a certain minimum amount of the game area shown, and show a bit more either horizontally or vertically depending on aspect ratio. Potentially unfair if you don't do anything else, but as you mentioned something like scaling object speeds can compensate.
Pad out the game area with some non-playing area parts (perhaps decorative, or containing parts of the controls, score display, etc.) Depending on device aspect ratio, different parts of this get cut off or shown. The real playing area is exactly the same dimensions on all devices.

Split Screen 2 Player Local Multiplayer with SpriteKit

I want to make a 2 player mode, split screen style, like Tiny Wings HD did where each side of an iPad gets a flipped orientation screen of the current Level.
I wanted to also implement it on tvOS (without the flipped orientation) as I feel TV begs for this sort of gameplay as it's pretty classic to have this style of gameplay on TV (e.g. Mario Kart 64 or Goldeneye).
Over on the Apple Developer forum, someone suggested that it could be done as follows, but, there we're no other responses.
"You can have two views attached to the main window (add a subview in your viewcontroller). To both views you can present a copy of the scene. Then you can exchange game data between scenes via singletons."
I was looking for a more in-depth explanation as I don't exactly understand what the answer is saying.
I'd just like to be able to have two cameras both rendering the same scene but one focusing on player 1 and the other player 2.
Obviously this isn't a simple answer, so I don't expect a full in-depth tutorial.
Unfortunately I could find no info on this.
Has anyone tried this?
A sample project would be ideal or some documentation/links that might help.
I'm sure a demonstration of this would be valuable to quite a lot of people.
No Cameras involved or necessary
The players just look like they're moving along the x axis because the backgrounds are scrolling by. You can allow the players to move up & down on the y axis whether jumping, ducking, rolling or following a path like in Tiny Wings, but the player never leaves their x position. You can even have each half of the screen background scrolling at different speeds to represent that one player is moving faster than the other.
In your update method in you scene file you can scroll your backgrounds, and in your touches methods you can jump, duck etc the players
Instead of using an SKView to present an SKScene, you can use SKRenderer and MTKView. SKRenderer renders a scene into a Metal pipeline, which in turn can be presented by an MTView.
Crucially, you can decide if SKRenderer updates the scene, allowing you to render the same scene frame multiple times (possibly using different cameras).
So a pipeline might look like this:
Apple actually talk about this option in Choosing a SpriteKit Scene Renderer. There's also a section about using SKRenderer in Going Beyond 2D with SpriteKit from WWDC17 which is quite helpful. This answer also shows how to use SKRenderer (albeit in Objective-C).

air resistance in sprite kit

This is my first time working with sprite kit and am trying to figure out how I would implement the effect of air resistance. I want to be able to create two different sprite nodes and have one behave like a bubble and the other like a rock. Right now they behave like they would in a vacuum (ignoring the fact that a bubble would pop in a vacuum).
So the questions is how can I add air resistance? I've tried linear dampening, but that doesn't seem to do the trick.

DeepEnd(cydia tweak) like 3D background for iOS

I am trying to emulate 3D background in one of the application we are developing.
Check this video on what i am trying to do : http://www.youtube.com/watch?v=429kM-yXGz8
Here is what i am trying to do to emulate this 3D illusion in our
application for iPad.
I have a RootView with 3 rounded buttons centered on the screen which animates in circular motion.
On bottom screen i have some banners of size (600*200) which keeps rotating with flip animation.
I also have some graphical text that is part of the background which contains the "Welcome message"
All elements are individual graphics, and hence when the user moves the iPad we only move the background based on the position of iPad using x,y,z coordinates of accelerometer.
the background moves accordingly, however this is not enough to have 3D illusion, so we decided to add some shadows to graphical elements(buttons, banners, text) and move the shadow accordingly with the iPad's position.
However the result is not convincing, and accelerometer is not updating value if user moves iPad to left and right on stand up position facing iPad straight to the head.
I was wondering if anyone have tried to achieve something similar with success? or any resource to help on how to achieve this? i am just confused whether by using only accelerometer will work or should i go with gyroscope?
Using face detection for simulating a 3D effect already has been done (by me). You can download a complete sample from http://evict.nl/code/face-tracking See the video on that page for a quick demo.
You should definitely use both. accelerometer (movement) and gyroscope (device angle). But for a true 3d effect you probably need to use the camera + face detection.

How to add continuous movement to iPad app

I'm writing a 3d car designer ipad app and I want to add a little "life" to it. I want it to be similar to what "3D Car Builder" iPad app does, in that from the moment the app starts, there's just the slightest amount of "movement" in the scene. Even if the iPad is sitting on the table, there's movement going on.
I'm testing on a 1st gen iPad, so whatever they've implemented, works on my device. I have (iOS 5 installed). I've looked up several things, thinking this was developed with the accelerometer, or possibly magnetometer, core motion of some sort...I can't figure out where to start. It might something as simple as moving the 3D scene in the x direction for a small amount, then y-direction, the negative x, then negative y. I dunno, it's something simple.
Anyone know how I/they might have implemented this?
Okay, nevermind...I figured this one out. Worked great using CCActionInterval

Resources