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
17
votes
2 answers

replacing CALayer and CABasicAnimation with SKScene and SKActions

I am trying to restructure this Github Swift project on Metaballs so that the circles are represented by SKShapeNodes that are moved around by SKActions instead of CABasicAnimation. I am not interested in the various Metaball parameters (the…
OnlyCodeMatters
  • 683
  • 1
  • 5
  • 15
17
votes
1 answer

iOS Universal Device App with SpriteKit, how to scale nodes for all views?

I want to make a landscape app to be universal, so that the sprite nodes scale proportionally to whatever view size is running the app. I'd like an entirely programmatic solution because I don't like the IB. My game is pretty simple, and I don't…
ljs
  • 315
  • 2
  • 10
17
votes
4 answers

iOS9 Sprite Kit issues

Everything was going so well until I upgraded to xCode 7 and iOS 9.... My current project is a 2D platform game, ever since the upgrade I've fallen fowl of the sprite kit bug/errors that many of us seem to be facing. My issue is that all sprites…
Rich Townsend
  • 571
  • 1
  • 5
  • 21
17
votes
2 answers

Xcode error: calling -display has no effect

Whenever I load my SpriteKit app, it logs this error: : calling -display has no effect., and it doesn't properly display many objects. I have tried recreating the scene and removing my code, both of which have done…
mhillsman
  • 770
  • 1
  • 8
  • 26
17
votes
2 answers

In swift how do I change the color of a SKSpriteNode?

I have created a game with an SKSpriteNode that is black and when the user touches the screen I would like for the SKSpriteNode to change to white. I have googled everything I can and attempted lots of different strategies with no luck. Does anyone…
Jacob Peterson
  • 343
  • 1
  • 4
  • 12
17
votes
3 answers

how to throw SKSpriteNode?

So basically in my game i need to toss or throw an object. So far i have a sprite, It can be dragged but it cannot be thrown. the games idea is to throw a sprite to collide with another sprite. I want the sprite which we will call testNode, To move…
Jesse Onolemen
  • 1,277
  • 1
  • 15
  • 32
17
votes
2 answers

no designated init for SKShapeNode(circleOfRadius: radius)

I'm trying to create a subclass of SKShapeNode in swift as SKShapeNode(circleOfRadius: radius) but there is no designated init for it. Anyone have any workarounds or info about why? I'm not sure if this is a bug or intentional. I found this…
Chris
  • 173
  • 1
  • 6
17
votes
6 answers

Blend UIColors in Swift

I have two SKSpriteNode and their colors are defined like this: colorNode[0].color = UIColor(red: 255, green: 0, blue: 0, alpha: 1) colorNode[1].color = UIColor(red: 0, green: 255, blue: 0, alpha: 1) and I want to have a third SKSpriteNode…
Drakalex
  • 1,488
  • 3
  • 19
  • 39
17
votes
3 answers

SpriteKit Nodes Sticking to Edges of Scene / Not Bouncing

I've searched this one and I think there must be some parameter to fix this but I haven't found it. I have a scene in SpriteKit where I want some circles/balls to bounce around and maintain any velocity they have indefinitely. They should bounce…
Jim
  • 343
  • 1
  • 3
  • 6
17
votes
12 answers

How to create progress bar in sprite kit?

I want to create my own progress bar in Sprite Kit. I figured I will need to images - one fully empty progress bar and filled progress bar. I have those images, I put filled one on top of empty one, they are regular SKSPriteNodes now I can't figure…
Dvole
  • 5,725
  • 10
  • 54
  • 87
17
votes
1 answer

Why SKShapeNode does not have anchor point?

i am trying to understand why SKShapeNode does not have an anchor point ?
Sureyya Uslu
  • 325
  • 4
  • 10
17
votes
2 answers

Detecting collisions in sprite kit

I'm trying to make a simple game with sprite kit. The basic idea is that there is one player who can jump to avoid blocks. But i have a problem I don't know how to make it that when the player hits the block the player disappears and the blood…
that guy
  • 404
  • 1
  • 7
  • 15
17
votes
1 answer

Making a particle follow a path in spriteKit

I have created a particle and when I test it moving on Xcode's property window, it looks like this: I have added this particle to a scene, made a circle and forced the particle to run that circle using this: NSString *myParticlePath =…
Duck
  • 34,902
  • 47
  • 248
  • 470
16
votes
2 answers

Multi-line label in swift 2 sprite-kit?

I need to be able to make a multi-line label in swift 2 sprite-kit for a game. The text needs to wrap around rather than go off of the screen. Bellow is what I have but I do not know what to do import Foundation import UIKit import SpriteKit class…
JaredD101
  • 161
  • 1
  • 3
16
votes
5 answers

A count of started touches is not equal to count of finished touches

I have the following code for testing purposes: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [self customTouchHandler:touches]; } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { [self…
Andrey Gordeev
  • 30,606
  • 13
  • 135
  • 162