air resistance in sprite kit - ios

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.

Related

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

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

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).

How to draw lines on the screen for an iOS game

I am working on a game where I need to draw a bunch of lines to create a wireframe sort of object, I can do this in sprite kit using nodes but adding a bunch of nodes to the screen will drop the frame rate down a lot. I don't know how to use OpenGL Es at all so that's not an option for me. Is there anything that would just allow me to draw lines on the screen in Sprite kit without adding nodes or is there another framework that will allow me to do that?
If you want a 3D wireframe then your choices are sprite kit (which is built on top of OpenGL), OpenGL, or Metal. Or I guess you could use somebody's 3rd party framework that is also built on top of OpenGL or Metal.
I tend to agree with nhgrif's comment that you're "I don't know xyz so I can't do that" is needlessly limiting. If you can't do anything that involves learning new APIs then you're never going to get very far as a developer.

Efficient way to draw many shapes on UIScrollView, scrollable and zoomable

I’m working on various iOS apps and I need an interface with the following capabilities:
I have a scrollview (covering most of the screen) which is scrollable both directions
This scrollable view contains a lot of rectangles. These rectangles are intractable. User can modify them, move them around, create and delete. So ideally they would be all CALayers or UIViews.
The problem is because there could be 100s or 1000s of those displayed at once, CALayers or UIViews may not be very efficient.
The scrollview could be 10-20 times bigger than the screen size itself. And fully covered with these shapes. So when the user scrolls it shouldn’t see any flickers or shapes appearing after the scrolling is done. e.g. If I use CATiledLayer and user scrolls, you can see things drawn after scrolling is done.
Smooth zooming. Zooming out is particularly challenging, because the shapes would need to be drawn on parts of the view which are going to become visible. Also, ideally I’d rather not use something like CGAffineTransform to perform scaling, I like to have a pixel accurate scaling.
I’ve tried various things, but I can’t seem to be able to get decent frame rates even on iPhone 6. Even tried drawing every frame, but it’s too expensive Core Graphics to handle it. Is there code examples someone trying to do a similar thing or an open source library? I’m trying not to use OpenGL, I feel like it’s an overkill, but I will try it if I have to. FYI, I have no experience in OpenGL yet.
Procreate for iPad does what I’m trying to do perfectly, it’s super responsive and zooming is pixel accurate. I know they use OpenGL and I’m not making drawing apps. The reason I mention it is because it shows what I’m trying to do is possible.
I think you need to move from UIKit to some 2d or 3d engines:
Cocos2D
Sparrow
Unity
OOlong

Creating a "puff of smoke" effect in iOS game

I would like to have some text appear and disappear in a puff of smoke effect in an iPhone game. For example, when someone scores points, I want to show the new points that were added. It should appear in a puff of smoke and disappear within a second or two.
How do I create that?
Have a look at Particle Designer from 71 Squared. It costs about $7.99 and includes easy code generation and integration. There are some pre-configured smoke effects available in the shared library.
http://particledesigner.71squared.com
You will most likely have kind of "cheap" effects using particles, but you'll have a good control over the animation (velocity, scaling, acceleration...).
Another way to go is to use multiple images of smoke and overlay them, then launch an UIView animation with random properties for rotating, scaling and timing.

Resources