Questions tagged [skspritenode]

An SKSpriteNode is a node that draws a textured image, a colored square, or a textured image blended with a color.

An SKSpriteNode is a node that draws a textured image, a colored square, or a textured image blended with a color.

SKSpriteNode is part of , a graphics rendering and animation infrastructure to animate arbitrary textured images, or sprites.

is available on iOS () and OS X ()

Click Here for Apple Docs.

1417 questions
6
votes
1 answer

Troubles to detect if a CGPoint is inside a square (diamond-shape)

I have 2 SKSpriteNode: a simple square (A) the same square with a rotation (-45°) (B) I need to check, at any time, if the center of another SKSpriteNode (a ball) is inside one of these squares. The ball and the squares have the same parent (the…
cmii
  • 3,556
  • 8
  • 38
  • 69
6
votes
2 answers

Creating a Divided Map Swift

I am creating a game in SpriteKit using Swift. The game requires the player to be able to select a certain state in the Unites States using a map like this. Is there a program or technique I could use in order to draw the outlines of the states,…
Aidan Kaiser
  • 501
  • 5
  • 17
6
votes
1 answer

Get child node of SKReferenceNode in SpriteKit SWIFT

I create a scene Case.sks (using Level Editor), inside one SKSpriteNode (name : square), and one SKLabel (name : label). In my main scene, GameScene.sks, I use a SKReferenceNode with "Case" for reference. I need to access to the "square" sprite from…
cmii
  • 3,556
  • 8
  • 38
  • 69
6
votes
1 answer

Has SpriteKit's coordinate system changed in Xcode 8?

In previous version of SpriteKit the origin (0,0) was always in the bottom left. Furthermore, Node's added to their parent, by default, started there. It seems that starting with Xcode 8, the new default origin is in the center of the screen. Is…
Kyle G
  • 4,347
  • 4
  • 26
  • 39
6
votes
2 answers

SpriteKit PhysicsBody: Could not create physics body for basic shape

I have an extremely basic polygon that is the texture for a sprite in my game, yet when I try and create a physicsBody from this texture for the sprite I get this error: 2016-06-19 08:25:21.707 Space Escape[14677:5651144] PhysicsBody: Could not…
6
votes
2 answers

How do I detect which SKSpriteNode has been touched

I find a similar question, but I am trying to detect and identify which Sprite the user touch, and I don't know how to do that. This is my variable: var sprites: [[SKSpriteNode]] = [[SKSpriteNode(imageNamed: "a"), SKSpriteNode(imageNamed: "b")],…
AnaMM
  • 307
  • 4
  • 17
6
votes
2 answers

Detect touch within Sprite texture and not the entire frame iOS Swift SpriteKit?

I am working with SpriteKit right now and I came across a problem that seems simple but I couldn't find anything on the internet. I have three buttons that are shaped like parallelograms stacked on top of each other and it looks like…
samando
  • 140
  • 1
  • 1
  • 10
6
votes
2 answers

Stop SKSpriteNode from slowing down

I am trying to keep my SKSpriteNodes moving at a constant speed forever, even after collisions. I have set gravity to 0, friction to 0, and linear and angular dampening to zero, but the Sprites still slowly slow down to zero velocity. How can I keep…
Siriss
  • 3,737
  • 4
  • 32
  • 65
6
votes
2 answers

Swift SKSpriteNode: Detect Tap / DoubleTap / LongPress

I'm attempting to create a subclass of SKSpriteNode which can detect user interaction (tap, double tap and hold), then defer to a delegate. This seems to me like a relatively common need, but: The code is incapable of detecting a double-tap without…
TheNeil
  • 3,321
  • 2
  • 27
  • 52
6
votes
2 answers

How to connect two SKSpriteNode's using SKPhysicsJointPin - swift

I am trying to connect two SKSpriteNode's using SKPhysicsJointPin at anchorPoint marked as green dot on screenshot below. Later I would like enable physicsBody!.dynamic = true on object2 to get "swing animation" of object2. I am having difficulty…
Omen
  • 139
  • 2
  • 13
6
votes
1 answer

PhysicsBody is nil using SpriteKit with Swift

I have a SpriteKit game I am building and I am loading a level from a multidimensional array. The loadlevel function works the first time. It does fail if I do a println of the physicsBody above the physicsBody assignment (after the initialization…
Johnston
  • 20,196
  • 18
  • 72
  • 121
6
votes
2 answers

Changing sprite Images in Sprite-Kit

Is there a way to change the image of a sprite which has already been initialized with another image? I tried: if ([node.name isEqualToString:@"NameX"]) { SKAction *fadeOut = [SKAction fadeOutWithDuration:0.3]; SKAction *fadeIn =…
user3138007
  • 637
  • 1
  • 6
  • 19
6
votes
1 answer

Why SKSpriteNode node.frame.size.width is smaller than node.size.width?

Why SKSpriteNode node.frame.size.width is smaller than node.size.width ? Here is example code ,probably you will need to insert your own image - (void)DrawRect:(SKSpriteNode *)node { SKShapeNode *rect = [[SKShapeNode alloc]…
Sureyya Uslu
  • 325
  • 4
  • 10
6
votes
2 answers

iOS SpriteKit how to create a node with an image from a folder within app bundle?

I'm trying to create a sprite of a random monster where my images are stored in a folder referenced within the main bundle. NSString* bundlePath = [[NSBundle mainBundle] bundlePath]; NSString* resourceFolderPath = [NSString…
Alex Stone
  • 46,408
  • 55
  • 231
  • 407
5
votes
3 answers

Getting the filename of an SKSpriteNode in Swift 3

How can I access the image filename from an SKSpriteNode? I have been trying to Google this, but no answer seems to be available. Here is the impotent part of my code: current_ingredient?.name = String(describing:…
thar
  • 1,094
  • 2
  • 13
  • 25