Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reasons to use CoreGraphics instead of SpriteKit?

SpriteKit runs efficiently on the GPU.

CoreGraphics runs on the CPU.

I can't think of any drawing that CoreGraphics can do that SpriteKit can't do.

Given this, can you name reasons for why someone may still want to prefer CoreGraphics over SpriteKit for new apps?

like image 801
code-ninja-54321 Avatar asked Jan 13 '17 12:01

code-ninja-54321


1 Answers

It's not an "either or" question, because there are disparities in their abilities.

Core Graphics can make very complex imagery, with incredibly sophisticated build ups of layers with differing effects and content. But most of all, it's very good at drawing shapes and lines at a quality that no other iOS framework matches. As Apple says:

Core Graphics... provides low-level, lightweight 2D rendering with unmatched output fidelity. You use this framework to handle path-based drawing, transformations, color management, offscreen rendering, patterns, gradients and shadings, image data management, image creation, and image masking, as well as PDF document creation, display, and parsing.

https://developer.apple.com/reference/coregraphics

You won't find PDF export creation, image creation (texture creation, yes, but not image creation), nor complex gradients, color management, complex patterns, transforms and offscreen rendering with a context in SpriteKit.

Similarly, you won't find the kind of anti-aliasing in Core Graphics in SpriteKit.

If you want to integrate your creations from image making into UIKit applications, you're far better off using a blend of Core Graphics, Core Image and Core Animation than even attempting to use SpriteKit for that kind of image creation and animation in an app.

Use SpriteKit for games that suitably benefit from the focus on Sprites as the primary graphic content.

You might, for example, choose Core Animation and Core Graphics for games that focus on more dynamic content or a demand for higher quality programmatically created content than you can get from just SpriteKit. Or you could use Core Graphics to make content for sprites at a higher quality than you'll ever get out of SKShapeNode.

So... horses for courses.

The courses being, basically:

A) Sprites and Simple 2D rendering and drawing

B) All kinds of graphics, dynamic drawing and much higher demands in quality and output types

or

C) A bit of a blend of both

like image 198
Confused Avatar answered Oct 22 '22 11:10

Confused