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.
Questions tagged [sknode]
331 questions
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
2 answers
SpriteKit: how to iterate through ancestors of a node?
We want to iterate through the ancestors of a node until we find a parent with a specific class.
SpriteKit lets you iterate through children with the children property, but the parent property only holds the immediate parent -- not an array of…

Crashalot
- 33,605
- 61
- 269
- 439
3
votes
0 answers
How to use SKNode fileNamed: initializer on any node that is not an SKScene
I have asked this similar question a while ago, but since then it seems SKNode now has this nifty initializer init?(fileNamed filename: String) that unarchives the scene from an .sks file. The thing is, this initializer is on SKNode, not SKScene,…

mogelbuster
- 1,066
- 9
- 19
3
votes
1 answer
Periodically add nodes to the scene with a random time interval in between
Simplified, I'm trying to figure out how to add lets say 10 nodes to my scene over some period of time, each seperated by some random time interval.
For example:
Loop 10 times:
A. Create and add node to scene
B. Wait some random amount of time,…

Brejuro
- 3,421
- 8
- 34
- 61
3
votes
1 answer
children's children with enumerateChildNodes(withName:using:)
does enumerateChildNodes(withName:using:) go through and search the children of children, and their children, etc?
Or does it just search the first generation of children?
Docs are here, and mention nothing about this:…

Confused
- 6,048
- 6
- 34
- 75
3
votes
2 answers
SpriteKit: how to smoothly animate SKCameraNode while tracking node but only after node moves Y pixels?
This question and others discuss how to track a node in SpriteKit using a SKCameraNode.
However, our needs vary.
Other solutions, such as updating the camera's position in update(_ currentTime: CFTimeInterval) of the SKScene, do not work because we…

Crashalot
- 33,605
- 61
- 269
- 439
3
votes
2 answers
Spritekit endless runner parent SKNode
I'm familiar with swift but I've started dabbling my hand in spritekit. I've been following a tutorial about created an endless runner. The approach taken by the author is to create a single SKNode that contains all the children. This container node…

TommyBs
- 9,354
- 4
- 34
- 65
3
votes
2 answers
How to stop an audio of SKSpriteNode after its removed from the scene(Swift)?
Here is my code:
override func didMoveToView(view: SKView) {
/* Setup your scene here */
let backgroundImage = SKSpriteNode(imageNamed: "Background.jpeg")
backgroundImage.size = self.frame.size
backgroundImage.position = CGPoint(x:…

Pruthvi Hariharan
- 551
- 1
- 6
- 23
3
votes
0 answers
How to add a UIView as a child of SKNode
I'm making a game using Objective-C and Sprite Kit and I've encountered a problem I can't get a workaround for so after hours of trying myself, I've considered asking you here.
I've created an animation using CoreAnimator and the result is given as…

Sisik2205
- 41
- 3
3
votes
1 answer
How to remove node when become outside the scene in Sprite Kit
I am trying to delete node when goes out side the scene and i tried this method to do it
if( CGRectIntersectsRect(node.frame, view.frame) ) {
// Don't delete your node
} else {
// Delete your node as it is not in your view
}
but it seems not…

RUON
- 163
- 9
3
votes
2 answers
swift - Jump only when landed
I'm looking to restrict my character (cat), to only jump when it's either on the ground (dummy SKNode), or when on the tree (treeP SKNode).
Currently I don't have any restrictions to touchesBegan and as a result the cat is able to fly through the…

Rich Townsend
- 571
- 1
- 5
- 21
3
votes
1 answer
Detect touch on SKNode (swift)
I have created a container node to put in all my SKSpriteNodes that need to be moved all in one touch, I can detect touches on them normally in iOS 8 but in iOS 7 I can only detect touches on my main node and when I touch an SKSpriteNode that it's…

Ludyem
- 1,709
- 1
- 18
- 33
3
votes
2 answers
Can I create SpriteKit texture atlas in runtime
I'm developing an os x / iOS crossword game which uses SKLabelNode to display the crossword letters as a child on a SKNode subclass.
So for each letter there is SKNode.SKLabelNode. Without using SKLabelNode the draw counts are in the range of 6-8.…

Simon Kemper
- 635
- 1
- 7
- 16
3
votes
0 answers
Clone a node in SceneKit
How can I create a copy of a node in SceneKit(using swift)? I have read Apple documentation but i didn't figure it out. I tried with clone() method and copy. But none of them gave results(actually nothing happened). Any hints?
Edit
Code is pretty…

Alec Firtulescu
- 543
- 6
- 18
3
votes
1 answer
How to get sun at noon shadow with SKLightNode
I'm playing around with SKLightNode. I'm trying to create shadows so that it would look like the sun is at noon. So basically something like this:
However all I can get SKLightNode to render for me is this:
So the problem is that it looks like the…

user3673836
- 591
- 1
- 9
- 23