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

SpriteKit Swift make an entire scene darker, then change it back

Is there any way to make an entire scene, including all of its children nodes (not just the background color) darker in color? I am looking for an effect similar to that of this code: node.color = SKColor.blackColor() node.colorBlendFactor =…
Noah Covey
  • 161
  • 2
  • 13
2
votes
1 answer

SKCameraNode functions containsNode() and containedNodeSet() aren't working as expected

I was trying to use the new SKCameraNode in iOS 9.0, but I encountered that the camera is always returning false for containsNode() and an empty set for containedNodeSet(). Just to test, I created an empty project with the SpriteKit template and…
2
votes
1 answer

Is the order of SKNode.nodesAtPoint guaranteed?

SKNode has a method nodesAtPoint which returns an array of children nodes that intersect given point. Is the order of the elements in such array deterministic (e.g. by drawing order)? I could not find an answer in documentation, so probably the…
0x416e746f6e
  • 9,872
  • 5
  • 40
  • 68
2
votes
1 answer

What does @"//" do in childWithName and when to use it

I'm working on a SpriteKit project and my SKSpriteNode has a simple name: node.name = @"cat" However, when I try to do [self childWithName:@"cat"], I do not retrieve my object. Through some research I noticed some people mentioning I should be…
Tim
  • 53
  • 4
2
votes
2 answers

Apply an impulse to SKNode to move across screen and detect collision

I am making a basic app that pushes shapes across the screen and detects collision with Sprite Kit. My first attempt was using moveTo on the nodes. The issue I had was with collision, the objects would rotate around each other instead of bounce. …
StuartM
  • 6,743
  • 18
  • 84
  • 160
2
votes
1 answer

SpriteNode Perspective?

Problem Trying to programatically change the SKSpriteNode perspective? i.e making the bottom of the image a greater width than the top of the image, or vice versa? Cannot find any search help for this in Sprite Kit.
Daniel
  • 285
  • 3
  • 12
2
votes
3 answers

Transitioning back to gamescene.swift causes error "'Attemped to add a SKNode which already has a parent"

My app contains two scenes. Playscene.swift and gamescene.swift. Transitioning from gamescene to playscene (where play takes place) works perfectly. However, once a gameover is reached, I have a "replay" button appear allowing the user to return…
mdd
  • 51
  • 7
2
votes
1 answer

Is the addChild method done synchronously or asynchronously?

I have a SpriteKit game where I check if my sknodes have a parent node during the SKScene's update method (by checking if their parent property is nil). If they don't have a parent node, then I know to add them to the SKScene. I'm worried that if…
Jordy
  • 415
  • 5
  • 13
2
votes
2 answers

Change properties for children of SKNode in a for loop

I understand that the children property of an SKNode is a read only property. Still, is there a way that in iterating over the children, it would be possible to change the properties of those children? For example: let background =…
Acoop
  • 2,586
  • 2
  • 23
  • 39
2
votes
1 answer

Sprite Kit turn node by Y

I have 2 nodes: SKShapeNode coin and SKSpriteNode hero with delegate and didBeginContact method. Contact works fine, but after i reverse my hero texture, nodes are don't interact. The logic is: hero is go on line, under line and above line…
user3312949
  • 145
  • 1
  • 9
2
votes
0 answers

SpriteKit - How to get an SKNode index for use in insertChild(_:atIndex:)

I have a ton of identical SKSpriteNodes added to my scene, all with the same zPosition, layered on top of each other according to the order they are added to the scene. I need to be able to pick one SKSpriteNode, and add another at the same index…
mogelbuster
  • 1,066
  • 9
  • 19
2
votes
2 answers

SpriteKit - Detect if node hits another nodes children and perform action

I have a Cat node, and a Bird node. The bird nodes are nested together in a container node called a birdBlock. Everything is contained in a WorldNode. If I add a bird to the WorldNode, the Cat can interact with it appropriately, but when the birds…
Siriss
  • 3,737
  • 4
  • 32
  • 65
2
votes
2 answers

Creating a convenience method for a subclassed SKNode object for all iOS versions

I´m creating a convenience method for a subclassed SKNode object using the code below. This seems to be working fine. What bugs me, is that the SKNode Class Reference explicitly states that the -init symbol is only available for iOS 8.0 and later.…
2
votes
1 answer

Adding, Removing, and Caching SKNodes

Background info: I'm creating a SpriteKit 2D platform-style game with multiple "floors". When the user enters a "portal" he is transported to another floor (either one up or one down). If the user dies at a different floor from where the most recent…
Aleksander
  • 2,735
  • 5
  • 34
  • 57
2
votes
3 answers

SKNode! is not convertible to "SKNode"

I got this problem and can't resolve it, I don't really understand the documentation on unwrapping variables var ladybug: SKNode = SKNode.childNodeWithName("ladybug") Error: (String!) -> SKNode! is not convertible to "SKNode" thanks
user3722523
  • 1,740
  • 2
  • 15
  • 27