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
3
votes
1 answer

AVAudioPlayer on background thread

I know very little about using background threads, but this seems to play my sound in the way that I need it to as follows: 1) I need this very short sound effect to play repeatedly even if the sound overlaps. 2) I need the sound to be played…
02fentym
  • 1,762
  • 2
  • 16
  • 29
3
votes
1 answer

How can I rotate a SpriteNode around the center of the screen?

I'm in the process of updating my current app, and I was wondering if there is a way to rotate a sprite node around the center? For example, Earth revolving around the Sun. I'm also using the sks file. This is what I have: import SpriteKit import…
behind the aura
  • 296
  • 2
  • 14
3
votes
2 answers

How can i check if two SKSpriteNodes are near each other?

How can i check if two SKSpriteNodes are near each other? like in a radius of 100. i am using the gamescene.swift and gamescene.sks.
user7206517
3
votes
0 answers

presentScene(... withTransition: SKTransition.fadeWithColor(customColor...) doesn't work with color with patternImage

I want to present SCNScene with SKTransition.fadeWithColor. It works good with standart colors like UIColor.greenColor(), but id does not work with color made with patternImage. Transition in this case is just transparent. Here is the code: guard…
Yurii Koval
  • 419
  • 5
  • 16
3
votes
2 answers

SpriteKit: run code or block when action removed?

The run function for SKNode lets you run a block when the action completes, but what if the action is cancelled/removed via removeAllActions? Cancelling an action doesn't invoke the completion block from the run function. Is there a callback or way…
Crashalot
  • 33,605
  • 61
  • 269
  • 439
3
votes
1 answer

SKLightNode is not zooming with SKCameraNode

In Sprite Kit, I'm using an SKCameraNode to zoom in and out of an SKScene. Any SKLightNodes in the scene are not zoomed at all. They are not children of the Camera so should not be invariant. Can't find anything on this - Search "SKLightNode…
Christian Cerri
  • 1,233
  • 2
  • 15
  • 19
3
votes
1 answer

Change the color of all nodes in a scene?

So this may seem like a stupid question; however, I'll see if anyone has an answer. Is there any way to change the color of all nodes in a scene in swift? For example invert all the colors? I've created a game using SpriteKit and would like to…
Matthew Anguelo
  • 293
  • 2
  • 12
3
votes
0 answers

Audio not working on device. Does work on simulator

I have created a Sound class and placed a method in my scene file to call the audio when the view begins. I have also linked the AudioToolbox.framework in the Build Phase. All runs fine on my simulator but the sound does not play on an actual…
michiel
  • 31
  • 3
3
votes
1 answer

Swift Spritekit I detect a collison but it reads the collision mulitple times

AppImage I have a wall of 4 rectangles that are different colors, to pass through the wall the color of the ball has to match that of the rectangle on the wall. The ball will pass through the wall, and a new wall will appear. However, when I detect…
raeman23
  • 51
  • 1
3
votes
1 answer

Change node.name inside of touch without running again?

I want to click on a certain spritenode and change the value of that spritenode. Here is the problem. When i do that, and set a if statement it knows to go to that if statement. However, i don't want it to run until next time the button is clicked.…
Matt Cantrelle
  • 151
  • 1
  • 8
3
votes
1 answer

having a node follow at a constant speed

I'm trying to make a small mini game where you drag a ball around the screen and every 10 seconds a ball gets added in that follows you. so far the you can drag a ball around the screen and a ball follows you, but when another ball gets added in the…
3
votes
1 answer

Move sprite along path

I'm working with SpriteKit and wondering if anyone knows how to make a sprite follow a path. I've seen other questions online that talk about moving a sprite along a CGPath, but how would you do it if the path is another sprite? Video example
Otto Gutierrez
  • 447
  • 2
  • 5
  • 15
3
votes
1 answer

Sprite Kit camera smooth movement with delay

So, I can make camera move with player, but it doesn't act the way I need it. I have set word boundaries: func keepPlayerInBounds() { if player.position.x < frame.minX + player.size.width/2 { player.position.x = frame.minX +…
3
votes
2 answers

Are SpriteKit Scene (.sks) files necessary in my project?

I tried searching and couldn't find the answer. Is it necessary to have a matching .sks file for each of my scene files? If I delete my matching .sks files will there be a problem? I understand this file is kind of for interface building but I…
Brejuro
  • 3,421
  • 8
  • 34
  • 61
3
votes
2 answers

SpriteKit sktilemapnode vertical line glitch

I am making a 2d platformer and I decided to use multiple tilemapnodes as my backgrounds. Even with 1 tile map, I get these vertical or horizontal lines that appear and disappear when I'm moving the player around the screen. See image below: My…
Discoveringmypath
  • 1,049
  • 9
  • 23
1 2 3
99
100