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

Swift - Must call a designated initializer of the superclass SKSpriteNode error

This code worked on first XCode 6 Beta, but on latest Beta it's not working and gives such errors Must call a designated initializer of the superclass SKSpriteNode: import SpriteKit class Creature: SKSpriteNode { var isAlive:Bool = false { …
Kosmetika
  • 20,774
  • 37
  • 108
  • 172
61
votes
11 answers

How do I detect if an SKSpriteNode has been touched

I am trying to detect if my sprite node has been touched and I have no idea where to start. let Pineapple = SKSpriteNode(imageNamed: "Pineappleimg") Pineapple.userInteractionEnabled = true Pineapple.position = CGPoint(x: CGRectGetMidX(self.frame) -…
James Brennan
  • 635
  • 1
  • 6
  • 7
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
28
votes
1 answer

Make SKSpriteNode subclass using Swift

I'm trying to create class which is a subclass of SKSpriteNode and I want to add other properties and functions to it. But in the first step I faced an error. Here's my code: import SpriteKit class Ball: SKSpriteNode { init() { …
Potter
  • 855
  • 2
  • 9
  • 9
24
votes
3 answers

SKAction how to combine withKey and completion

I´m quite new to iOS and Sprite Kit programming and wonder how to combine: -[SKAction runAction:withKey:] and -[SKAction runAction:completion:] On the one side, I want to prevent a node from running the same action (or action sequence) again, on…
Macilias
  • 3,279
  • 2
  • 31
  • 43
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
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
15
votes
1 answer

How to cut random holes in SKSpriteNodes

Aside from the fact that the question asked here : Draw a hole in a rectangle with SpriteKit? has not satisfactorily been answered in its own right, the most significant difference between the two is that this question requires an absence of…
Confused
  • 6,048
  • 6
  • 34
  • 75
12
votes
3 answers

Setting background color for SKLabelNode?

I want to know is there a way to set background color for a SKLabelNode not font color. I'm looking for something like below mentioned code, which is available in ios apps. label.backgroundColor = [UIColor redColor];
Jaffer Sheriff
  • 1,444
  • 13
  • 33
12
votes
3 answers

Centre a SKLabelNode on a SKSpriteNode

I have an SKLabelNode that is the child of a SKSpriteNode because I'm trying to create a Button class to create buttons in an easier way. I've tried a couple of things using the anchor point of the SKSpriteNode, but I don't quite understand exactly…
02fentym
  • 1,762
  • 2
  • 16
  • 29
12
votes
4 answers

Subclassing SKNodes created with SpriteKit .sks scene file

(this is for XCode 6 and iOS 8 beta 4) Love the new SceneKit editor. I'm successfully loading the scene from .sks file into a custom SKScene class. However, objects inside it are instantiated as default classes (SKNode, SKSpriteNode, etc), and i'm…
Rudi
  • 2,450
  • 5
  • 26
  • 37
11
votes
1 answer

Troubles using CGPathContainsPoint SWIFT

I need to check if a CGPoint is inside a SKSpriteNode. After a little research, CGPathContainsPoint seems appropriated for my purpose. if CGPathContainsPoint(my_sprite_path, nil, my_point, false) { } But Xcode alerts me: Use of unresolved…
cmii
  • 3,556
  • 8
  • 38
  • 69
11
votes
3 answers

What is wrong with the coordinate system in this SpriteKit setup?

I created a SKView which presents an SKScene subclass like this: SKView *skv = [[SKView alloc] initWithFrame:self.view.bounds]; [self.view addSubview:skv]; self.skScene = [[TestScene alloc] initWithSize:v.bounds.size]; [skv…
openfrog
  • 40,201
  • 65
  • 225
  • 373
11
votes
4 answers

How to rotate an SKSpriteNode around the node's Y-axis?

I'm trying to rotate an SKSpriteNode node around it's Y-axis. I know there's the zRotation property and that will rotate the node clockwise or counter-clockwise; however, I'd like to rotate the node around it's own Y axis (like a dancing ballerina…
pikovayadama
  • 808
  • 2
  • 8
  • 26
9
votes
2 answers

Merging or flattening background nodes to improve game performance?

I want to be able to improve my game's performance by somehow "flattening" my background nodes. This youtube video demonstrates how I build up my background graphics. But, I have my background graphics set up like this. I use two textures like…
Corey F
  • 621
  • 4
  • 14
1
2 3
94 95