Dynamic Bezier drawing in a spritekit game - Best (performance) approach? - ios

I am not an iOS developer, I just started to implement my game, that I have done in flash, hoping that it will be super fast using the native environment.
The project is a 2d game that has a lot of dynamic bezier drawing based on the user's interaction. Basically I draw dynamic blobs (amoeba type of shapes).
First I tried Swift, which is very similar to actionscript, but it turned out, Apple won't be able to accept apps built with Swift before the final release of Xcode6 and as I want release my game before September I went to objective C route.
I wanted to use sprite kit because of the integrated physics engine, sprite hierarchy, etc.
I tried to use SKSphapeNode for drawing, but I realised it very quickly, it is not suitable for my needs. (cannot draw a stroke if it is thicker than 2 pixels, it has memory leaks etc.)
So I used UIBezierPath that I put into an UIImage, but I am not happy with the performance as I have to create a new UIImage with the new dynamically generated bezier shape.
These are the options I found so far:
SkShapeNode - not suitable for my game
UIBezierPath - UIImage > I have to create a new UIImage every frame, so it is slow
OpenGL - I haven't tried it yet, I am not sure it is possible to use it with Sprite kit
CALayer - I am trying to integrate it with spritekit at the moment, but I have a feeling I will have the same problem that I had with the UIImage approach.
Does anybody have any idea, tip what approach would be the best performance-wise?
Thank you for your help in advance!

I tried to create a lightning effect with using SpriteKit, so check out my article about that: https://andreygordeev.com/2014/11/01/lightning-with-srite-kit.html
Some of the approaches use UIBezierPath, so may be you find that useful.

Related

Move sprite along path

I'm working with SpriteKit and wondering if anyone knows how to make a sprite follow a path. I've seen other questions online that talk about moving a sprite along a CGPath, but how would you do it if the path is another sprite?
Video example
Have a look at Is there a way to create a CGPath matching outline of a SKSpriteNode? - it seems from that answer that the problem is much more complex than it first appears.
If your sprite is an SVG, a simpler solution may be to manually convert the SVG into a CGPath, and then using that CGPath in your game. A simple tool for doing that is available here: https://swiftvg.mike-engel.com/. Of course doing this manually won't scale well if you have many different sprites.
This may not be exactly the answer you are looking for, but it seems right now there is no simple way to accomplish what you need :)

How to make speech bubble (callout) on SpriteKit iOS?

I'm creating a game for children using SpriteKit framework in iOS.
In my game, there are many speech bubbles which should be drawn by code.
I googled around and found intructions about using SKShapeNode to do it, but I haven't found a full Objective-C source code.
Has anyone done this before?
You can use the speech bubble you have already posted and display it as a SKSpriteNode with texture or image. Depending on your code set limitations, you can scale the y-axis for more or less text lines. Add SKLabelNodes to the bubble as children.

I need help to draw an icosahedron 3D object in an UIKit app

Although I am quite experienced with most frameworks in iOS, I have no clue when it comes to 3D modelling. I even worked with SpriteKit, but never with something like SceneKit.
Now a customer wants a very ambitious menu involving a 3D object, an 'icosahedron' to be exact. I want it to look something like this:
So I just want to draw the lines, and grey out the 'see-through' lines on the back. Eventually I want the user to be able to freely rotate the object in 3D.
I already found this question with an example project attached, but this just draws a simple cube: Stroke Width with a SceneKit line primitive type
I have no clue how to approach a more complex shape.
Any help in the right direction would be appreciated! I don't even need to use SceneKit, but it seemed like the best approach to me. Any other suggestions are welcome.
to build an icosahedron you can use SCNSphere and set its geodesic property to YES.
Using shader modifiers to draw the wireframe (as described in Stroke Width with a SceneKit line primitive type) is a good idea.
But in your case lines are not always plain or dotted — it depends on the orientation of the icosahedron. To solve that you can rely on gl_FrontFacing to determine whether the edge belongs to a front-facing or back-facing triangle.

Creating custom physic bodies

I'm trying to create the physicsbody for a custom image, but it's quite hard to do it the manual way using CGPath. On iOS8, we can call bodyWithTexture method for SKPhysicsBody, however in iOS7, I have to do it manually.
Is there an easy way for making physics body of complex textures?
Dazchong site is down and I tried a few other tools which didn't help.

Using OpenGL on top of a MKMapView?

I've got some data that I would like to render on top of a MKMapView using OpenGL. Currently I can sort of achieve this by placing a transparent OpenGL layer on top of the MKMapView and drawing to it using OpenGL commands.
However, the problem becomes synching the drawing of the OpenGL layer with the drawing that MKMapView does. I can kind of get around this by drawing on touch events, this works well until you "flick" the map which causes a continuous series of draws for the animation that I don't detect.
Another idea was to use a MKOverlayView and hope that OpenGL drawing could be done with it. But I'm not sure how exactly to app
I would recommend evaluating BA3's "Altus" mapping engine. It is built entirely in OpenGL, so in the worst case you may simple render to the same context. However, it would probably be better if you could take advantage of their support for geo-located raster, vector and marker elements.
Full disclosure: I'm friends with the authors, but have no financial interest.

Resources