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
20
votes
4 answers

Is it possible to rotate a Node around an arbitrary point in SpriteKit?

Is there a way to rotate a Node in SpriteKit around an arbitrary point? I now I can manipulate the anchorPoint of my Node, but that is not sufficient if the rotation point I want to use lies outside of the Node. What is the best way to achieve this…
Ben-G
  • 4,996
  • 27
  • 33
19
votes
1 answer

Can't open particle SKS files

I've been making a game with Xcode 6 GM using SpriteKit, and for some reason out of the blue a number of my .SKS particle files are now crashing Xcode which makes them impossible to open. I've also noticed that the files that are crashing Xcode are…
Epic Byte
  • 33,840
  • 12
  • 45
  • 93
19
votes
3 answers

Swift iOS playground: Error sending deferral props

With an iOS playground set up as simply as this: import UIKit import SpriteKit import XCPlayground let s = CGSize(width: 300, height: 300) let f = CGRect(origin: CGPointZero, size: s) let view = SKView(frame: f) let scene = SKScene(size:…
maltalef
  • 1,507
  • 2
  • 16
  • 27
19
votes
6 answers

Why are didBeginContact called multiple times?

In an iOS game that uses Sprite Kit along with the contact detection in Sprite Kit's build-in physics engine, I decrease the Hero's number lives by one each time he gets in contact with an enemy. This is done from the didBeginContact…
someName
  • 1,275
  • 2
  • 14
  • 33
19
votes
2 answers

Draw smooth circle in iOS sprite kit

I try to draw a single circle in my iOS SpriteKit project but the edges of the circle are not smooth. I would like to have a nicely drawn circle as I would draw it with Photoshop (anti-aliasing). I found several similar questions but the my problem…
xpepermint
  • 35,055
  • 30
  • 109
  • 163
19
votes
3 answers

Change a SKSpriteNode Image

i'm new to sprite Kit and having an issue with changing a current SKSpriteNode image. My spriteNode looks like this mover = [SKSpriteNode spriteNodeWithTexture:Texture1]; [mover setScale:1.0]; [self addChild:mover]; then i have this method that…
user3423384
  • 667
  • 2
  • 8
  • 18
19
votes
1 answer

SpriteKit: Preload sound file into memory before playing?

Just wondering if this is possible. Currently, the first time I play a sound file while the app is running, there is a noticeable delay before the sound actually plays (like it's caching it or something). After this it plays instantly without issue,…
alduin
  • 317
  • 3
  • 11
19
votes
1 answer

Change spritekit particle color

Is it possible to change the color of a particle after creating in the spritekit editor? I tried setParticleColor but it doesn't appear to do anything. Basically I want to have one particle file and a way to programmatically change the color on the…
Negora
  • 281
  • 4
  • 13
19
votes
10 answers

Constant movement in SpriteKit

I have a game where I would like to move an SKNode left or right depending on if the user touches the left or right side of the screen. How to I apply a constant movement to a node while the user is touching the screen?
user1007895
  • 3,925
  • 11
  • 41
  • 63
19
votes
3 answers

Load a .tmx (Tiled Map) in Sprite Kit?

Is there a (preferably easy) way to load a .tmx file in iOS 7's Sprite Kit? If not, are there any alternatives?
joeelectricity
  • 239
  • 1
  • 2
  • 13
18
votes
2 answers

How to limit the movement of two anchored lines so they swing continually like a pendulum

I have created two lines anchored to a sprite, which are 30˚ apart. I want both lines to swing left and right like a pendulum, always swinging from end to end (in such a way that they are swinging 45˚ to the left and right of their initial…
iGetIt
  • 695
  • 5
  • 20
18
votes
2 answers

Stopping an running SKAction - Sprite Kit

The following code will animate a rotation. let something:SKSpriteNode = SKSpriteNode() func start(){ let rotateAction = SKAction.rotateToAngle(CGFloat(M_PI), duration: 10.0) something.runAction(SKAction.sequence([rotateAction])) } Now I want…
Clinton Lam
  • 687
  • 1
  • 8
  • 27
18
votes
1 answer

What's the relationship between GameScene.swift and GameScene.sks files in SpriteKit template

I've been playing around with SpriteKit, and am getting a pretty decent feel about how to drive it from code, but am pretty baffled by the level editor included in Xcode 6. I've watched the wwdc videos ("platforms state of union" and "what's new in…
Steven Hovater
  • 1,389
  • 2
  • 12
  • 25
18
votes
4 answers

Change texture on SKSpriteNode

I have an SKSpriteNode and I want to change the texture on it when the user touches the screen. But cannot work out how to do so. Creating and adding the head. (Declared in header). head = [SKSpriteNode spriteNodeWithImageNamed:[NSString…
zipie
  • 199
  • 1
  • 1
  • 7
17
votes
1 answer

Game Center Challenges in iOS 10

I've implemented Game Center features like achievements and leaderboards, and now I'm working on the challenges. I was under the impression that I didn't have to add any additional code - if I had achievements or leaderboards, players would be able…