Questions tagged [sprite-kit]

SpriteKit is Apple's framework for creating 2D games for iOS 7+, macOS 10.9+, tvOS 9+ and watchOS 3+. It is a 2D rendering engine combined with a physics engine. It is compatible with both Objective-C and Swift.

SpriteKit provides a graphics rendering and animation infrastructure that you can use to animate arbitrary textured images, or sprites. SpriteKit uses a traditional rendering loop where the contents of each frame are processed before the frame is rendered.

SpriteKit is available on iOS (), macOS (), tvOS () and watchOS (). It uses the graphics hardware available on the hosting device to composite 2D images at high frame rates. SpriteKit supports many different kinds of content, including:

  • Untextured or textured rectangles (sprites)
  • Text
  • Arbitrary CGPath-based shapes
  • Video

SpriteKit also provides support for cropping and other special effects; you can apply these effects to all or a portion of your content. You can animate or change these elements in each frame. You can also attach physics bodies to these elements so that they properly support forces and collisions. Physics bodies can be created as rectangles or circles, follow CGPaths, or use an image's alpha to create a more complex physics body.

Since SpriteKit supports a rich rendering infrastructure and handles all of the low-level work to submit drawing commands to OpenGL () or Metal, you can focus your efforts on solving higher-level design problems and creating great gameplay.

Resources:

13201 questions
28
votes
1 answer

Make SKSpriteNode subclass using Swift

I'm trying to create class which is a subclass of SKSpriteNode and I want to add other properties and functions to it. But in the first step I faced an error. Here's my code: import SpriteKit class Ball: SKSpriteNode { init() { …
Potter
  • 855
  • 2
  • 9
  • 9
28
votes
4 answers

ios Sprite Kit screengrab?

I am trying to get a screen grab of a view that has a SKScene in it. The technique I am using is: UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, scale); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage…
Siegfoult
  • 1,844
  • 17
  • 19
28
votes
4 answers

Horizontally mirror a SKSpriteNode texture

I'm developing an iOS7 game with the new API called Sprite Kit. I'd like to horizontally rotated a SKSpriteNode image/texture. I've tried it by first mirroring the image, then creating a SKTexture and finally applying it to the SKSpriteNode but it…
Marti Serra Vivancos
  • 1,195
  • 5
  • 17
  • 33
27
votes
3 answers

Pausing a sprite kit scene

@property (SK_NONATOMIC_IOSONLY, getter = isPaused) BOOL paused; I found this line of code that I could add into my project, how would I pause my whole game? For example: -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ for (UITouch…
temp
  • 639
  • 1
  • 8
  • 22
27
votes
2 answers

Run two SKActions at once

I'm using a sequence to run a list of SKActions. What I want to do however, is run an SKAction, then run two at once, then run one in sequence. Here is my code: SKNode *ballNode = [self childNodeWithName:@"ball"]; if (ballNode != Nil){ …
Max Hudson
  • 9,961
  • 14
  • 57
  • 107
27
votes
7 answers

Sprite Kit & playing sound leads to app termination

using ARC Just a problem I've run into- I have an SKScene in which I play a sound fx using SKAction class method [SKAction playSoundFileNamed:@"sound.wav" waitForCompletion:NO]; Now when I try to go to background, no matter that the sound was over,…
Lior Pollak
  • 3,362
  • 5
  • 27
  • 48
25
votes
7 answers

How Do I Blur a Scene in SpriteKit?

How would I add a gaussian blur to all nodes (there's no fixed number of nodes) in an SKScene in SpriteKit? A label will be added on top of the scene later, this will be my pause menu. Almost anything would help! Something like this is what I'm…
Zane Helton
  • 1,044
  • 1
  • 14
  • 34
25
votes
7 answers

How to rotate a sprite node in sprite kit?

I am making a game and I'm having troubles with rotating a sprite node, This is the code I have; What do I have to add to turn it, let's say 45 degrees?. SKSpriteNode *platform = [SKSpriteNode…
Vince
  • 648
  • 1
  • 7
  • 17
24
votes
2 answers

CUICatalog: Invalid Request: requesting subtype without specifying idiom

Whenever I run my sprite kit app this error is logged constantly. It makes it really hard to debug because the log is filled with these messages. They don't seem to effect how the app runs, so simply suppressing the error would be sufficient. Anyone…
mhillsman
  • 770
  • 1
  • 8
  • 26
24
votes
3 answers

SKAction how to combine withKey and completion

I´m quite new to iOS and Sprite Kit programming and wonder how to combine: -[SKAction runAction:withKey:] and -[SKAction runAction:completion:] On the one side, I want to prevent a node from running the same action (or action sequence) again, on…
Macilias
  • 3,279
  • 2
  • 31
  • 43
24
votes
6 answers

SKShapeNode - Animate color change

I'm working on a game with SpriteKit. I'm drawing a shape with SKShapeNode. Now I want to animate its colour change but the SKActions is not working for SKShapeNode. Is there any way to do this or I have to use a different approach? Thank…
adam
  • 807
  • 3
  • 11
  • 17
23
votes
1 answer

Duplicating a particle emitter effect in Sprite Kit

I need to have a particle emitters effects to appear duplicated in 2 spots (For split screen purposes), I am wondering if anybody has come across a way of doing this. My goal is to have this running on iOS 10. Here is what I have tried so…
Knight0fDragon
  • 16,609
  • 2
  • 23
  • 44
23
votes
4 answers

Adding Convenience Initializers in Swift Subclass

As a learning exercise I am trying to implement a subclass of SKShapeNode that provides a new convenience initializer that takes a number and constructs a ShapeNode that is a square of number width and height. According to the Swift Book: Rule 1 If…
Alex Pretzlav
  • 15,505
  • 9
  • 57
  • 55
23
votes
3 answers

How can you create a glow around a sprite via SKEffectNode

I have a SKSpriteNode that I'd like to have a blue glow around it's edges for highlighting purposes. I am guessing that I would need to make my sprite a child of a SKEffectNode and then create/apply a filter of some sort. UPDATE : I have…
prototypical
  • 6,731
  • 3
  • 24
  • 34
22
votes
1 answer

How to guide tvOS focus items for curved SKNodes

My tvOS app generates a game board using SKNodes that looks like the following: Each shape, separated by lines, is an SKNode that is focusable (e.g. each colored wedge is composed of 5 SKNodes that gradually diminish in size closer to the…
Aaron
  • 6,466
  • 7
  • 37
  • 75