Questions tagged [sknode]

The SKNode class is the fundamental building block of most Sprite Kit content. All visual elements in a Sprite Kit-based game are drawn using predefined SKNode subclasses.

331 questions
3
votes
1 answer

Why does [NSSet containsObject] fail for SKNode members in iOS8?

Two objects are added to an NSSet, but when I check membership, I can't find one of them. The test code below worked fine in iOS7 but fails in iOS8. SKNode *changingNode = [SKNode node]; SKNode *unchangingNode = [SKNode node]; NSSet *nodes = [NSSet…
Karl Voskuil
  • 750
  • 6
  • 19
3
votes
1 answer

Trying to resize sknode produces error "Cannot assign to the result of this expression"?

I have created a subclass of SKNode called level and I'm trying to change it's size, however I get the error "Cannot assign to the result of this expression". What am I doing wrong? class Level: SKNode { override init() { super.init() …
lisovaccaro
  • 32,502
  • 98
  • 258
  • 410
3
votes
2 answers

SKPhysicsWorld Simulate Physics in Scaled Nodes

I'm attempting to build a SpriteKit game which involves levels with physics bodies which can be zoomed in and out on. The physics world is not behaving as I would expect and causing strange things to happen when the zoom level is changed. The nodes…
Anthony Mattox
  • 7,048
  • 6
  • 43
  • 59
3
votes
1 answer

Checking an SKNode is onscreen and visible

Is there a way to check when a SKSpriteNode / SKNode is onscreen (i.e. visible) I have a large scrolling background where I am spawning mobs, but I want to limit their animations and sounds if they are not visible. Is there a way to do this, I could…
fuzzygoat
  • 26,573
  • 48
  • 165
  • 294
3
votes
1 answer

iOS7 Sprite Kit can I archive the entire scene and use it as a save game?

I'm looking at the userData property of SKNode and noticed this statement: Sprite Kit does not do anything with the data stored in the node. However, the data is archived when the node is archived. This got me thinking - is it possible to…
Alex Stone
  • 46,408
  • 55
  • 231
  • 407
3
votes
4 answers

Sprite Kit: How To Subclass SKNode to create a Vehicle class (complex object with joints)

Has anyone figured out (natively) how to subclass SKNode to include multiple bodies connect by joints - for instance, a car? There doesn't seem to be a way to add the sub class's joints to the parent scene's physicsWorld property. Also, when trying…
user1052888
2
votes
0 answers

Does SKNode have an actions property?

I wondered if there was an easy way to see a list of all actions currently assigned to a node in SpriteKit. Something like an "actions" property that will contain a list of all a node's actions. The documentation for SKNode does not show anything…
peacetype
  • 1,928
  • 3
  • 29
  • 49
2
votes
0 answers

Custom SKNode object is not shown | Swift

I programmed an SKButton class. The problem is that the button doesn't show up in my scene even though I added it to this one. I also programmed a joystick, but it is displayed. What did I do wrong? SKButton: import SpriteKit class SKButton: SKNode…
chicken
  • 21
  • 4
2
votes
1 answer

onTouchesBegan() not being called for my custom SKNode

I'm trying to design my own DPad for my game but for some reason my onTouchesBegan() is not being called. I explored a bit and I think the reason for this is because my self.frame.size is equal to (0,0) for some reason even after I have added my…
Brejuro
  • 3,421
  • 8
  • 34
  • 61
2
votes
0 answers

SpriteKit: blurred background SKNode

How can I blur the background of a single transparent SKNode, while leaving the main background clear? I want something like this: The background is a single root SKNode and there's another SKNode added as a child. The child node is transparent…
bcattle
  • 12,115
  • 6
  • 62
  • 82
2
votes
1 answer

SKAction.rotate not running on SKCameraNode

So the actual SKCameraNode is working fine, since I make it follow another node and that works just fine. But when I try to rotate the camera with an SKAction, it won't rotate. When I try to set its zRotation though, it works fine. I don't really…
J. H.
  • 79
  • 9
2
votes
1 answer

SpriteKit: How to detect touches on node that began outside of node

SKNode A is a parent of SKNode B. If touches begin inside of SKNode B, the touchesMoved(_ touches: Set, with event: UIEvent?) function gets called. If, however, the touches begin outside of SKNode B but move into SKNode B, the touchesMoved…
Crashalot
  • 33,605
  • 61
  • 269
  • 439
2
votes
0 answers

Get parent of a node referenced by SKReferenceNode in Sprite Kit

I'm using Xcode's Scene Editor to build a GameScene. In the GameScene.sks file, I have added an SKReferenceNode that I named componentReference. This reference node references Component which represents the file Component.sks. Component.sks…
thecanteen
  • 762
  • 5
  • 13
2
votes
1 answer

Check if SKNode has a certain action running

I have a SKNode that is running different actions. Depending on the running action I want to trigger other behaviours. For that I would need to find out how to check which action is currently running on my SKNode. I know of .hasActions() but this…
boehmatron
  • 713
  • 5
  • 15
2
votes
0 answers

SKShapeNode inside another one, limited by parent bounds

All right, so let's say I have two SKShapeNodes (or any SKNode related object), one is a circle, and the other is a square. I'm just trying to put the square inside the circle so it looks like this: However, if I simply add the Square Shape Node…
ThiagoAM
  • 1,432
  • 13
  • 20