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

How to bring a SKSpriteNode to front?

How can I bring a SKSpriteNode to the front of all other node? With UIView, I can use bringSubviewToFront to bring an uiview in front of other views.
Phuong Ly
  • 383
  • 1
  • 3
  • 4
36
votes
7 answers

Physicsbody doesn't adhere to node's anchor point

My scene has a bunch of rectangles with physics bodies that are the same size as the rectangle. I like to anchor all of my objects to CGPointZero, however I've noticed when I do that the physicsbody remains anchored in the middle. In other words,…
Sophie McCarrell
  • 2,831
  • 8
  • 31
  • 64
36
votes
17 answers

Insert line break using SKLabelNode in SpriteKit

Simple question on how to insert a line break using SKLabelNode class in SpriteKit. I have the following code but it does not work - SKLabelNode *nerdText = [SKLabelNode labelNodeWithFontNamed:@"Times"]; NSString *st1 = @"Test break"; …
Arjun Busani
  • 550
  • 1
  • 7
  • 15
34
votes
9 answers

Background image size Sprite Kit Game

i just started a new Sprite Kit project to learn how to use it. I watched and read a lot of tutorials but no tutorial has a answer for my question/problem. I want to create an application just for my iPhone 5S. So the screen size is 1136x640. I…
Mike_NotGuilty
  • 2,253
  • 5
  • 32
  • 64
33
votes
5 answers

SpriteKit - Creating a timer

How can I create a timer that fires every two seconds that will increment the score by one on a HUD I have on my screen? This is the code I have for the HUD: @implementation MyScene { int counter; BOOL updateLabel; SKLabelNode…
user3578149
  • 475
  • 1
  • 5
  • 11
32
votes
7 answers

iOS Builds: This build is invalid in iTunes connect

I recently uploaded an app to the app store and its been processing for a few days now. I went in this morning to check everything out, and on the top bar of iTunes connect, i clicked on iOS builds to see how everything was going and I got a red…
Rae Tucker
  • 523
  • 1
  • 6
  • 16
31
votes
5 answers

CGPointMake in Swift

How to use CGPointMake in Swift? Is there an equivalent for it? I am getting an error: Use of unresolved identifier 'CGPointMake' Basically, I am trying to assign a position to a Sprite Kit node and cannot figure out how to do it in Swift. class…
Rafał Sroka
  • 39,540
  • 23
  • 113
  • 143
31
votes
1 answer

Sprite Kit - SKShapeNode Path not drawing Quad Curve

I have been delving in to Apple's new Sprite Kit, and been using it for a while now. However I ran into an issue when trying to draw a curved path for an SKShapeNode. It just appears to draw a straight line instead. Here is a very simple example of…
David Williames
  • 1,109
  • 9
  • 11
31
votes
8 answers

Is there a way to visually see sprite kit's SKPhysicsbody borderline?

I am using bodyWithPolygonFromPath to define the volume of a physics body, and I used http://dazchong.com/spritekit/ to get the paths required. But the path does not seem correct and I wish to see the borderline of the physics body path to see if…
user2832367
  • 381
  • 1
  • 3
  • 8
31
votes
2 answers

List of fonts that can be used with SpriteKit's labelNodeWithFontNamed method

How can I get the list of font names that can be used with SpriteKit's labelNodeWithFontNamed method? There is a method of SKLabelNode where I can specify the font name but I would like to know which fonts are supported and what are their…
Rafał Sroka
  • 39,540
  • 23
  • 113
  • 143
30
votes
2 answers

iOS Simulator games run very slow (low fps)

Diving into sprite kit (xcode 5). There are two example programs I'm working with, 1. the default spaceship example that's included when creating a new project and 2. the Adventure Game, which I downloaded. Running these examples within the iOS…
user1068477
29
votes
4 answers

Could not cast value of type 'UIView' (0x112484eb0) to 'SKView' (0x111646718)

Could not cast value of type 'UIView' (0x112484eb0) to 'SKView' (0x111646718). I keep on getting this error. Can anyone help me because the line of code is there by default. I converted the SK game into the latest swift syntax using the xcode 7…
Aryaman Goel
  • 538
  • 1
  • 4
  • 15
29
votes
5 answers

How to draw a circle in swift using spriteKit?

I just started doing ios development with swift and I can't figure out how to draw a circle. I'm just trying to draw a circle, set it to a variable and display in on the screen so I can later use it as the main player. Could anyone tell me how to…
elpita
  • 1,085
  • 3
  • 12
  • 13
29
votes
9 answers

How to define category bit mask enumeration for SpriteKit in Swift?

To define a category bit mask enum in Objective-C I used to type: typedef NS_OPTIONS(NSUInteger, CollisionCategory) { CollisionCategoryPlayerSpaceship = 0, CollisionCategoryEnemySpaceship = 1 << 0, CollisionCategoryChickenSpaceship = 1…
Rafał Sroka
  • 39,540
  • 23
  • 113
  • 143
28
votes
2 answers

How does collisionBitMask work? Swift/SpriteKit

As far as I'm aware the default for Physics bodies is to bounce off each other when they hit each other until you set their collisionBitMask to an equal number. However, I'm having a huge issue accomplishing what seems like it should be very simple…
Barkley
  • 6,063
  • 3
  • 18
  • 25