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
1
vote
0 answers
Being notified of SKPhysicsBody resting change
I’m using KVO to figure out if the resting property of my SKNode’s physicsBody has changed. But this runs tens of thousands of times per 30 seconds and is expensive.
Is there another way to figure out if the resting property changed inside a…

Adam Carter
- 4,741
- 5
- 42
- 103
1
vote
0 answers
Swift random point on screen for SKNode
I am trying to generate a random point on the screen to create an SKSpriteNode:
let px : CGFloat = CGFloat(drand48())
let py : CGFloat = CGFloat(drand48())
let screenSize : CGRect = self.frame
let location = CGPoint(x: screenSize.width*px,y:…

Ben Sisson
- 33
- 5
1
vote
0 answers
Why doesn't SKNode convertPoint:fromNode work between siblings?
I'm trying to use the following SKNode method:
public func convertPoint(point: CGPoint, fromNode node: SKNode) -> CGPoint
The method works as I'd expect in some situations, but not in others. For example:
class ViewController: UIViewController {
…

antsyawn
- 971
- 10
- 17
1
vote
1 answer
Randomly spawn SKNode on the x position?
I have a game and I can't seem to get the node to randomly spawn on x position, it will randomly spawn but often will go off screen and the game is then useless and have to restart it:
func addEnemy () {
//enemy
let minValue =…

Tye Howatt
- 105
- 2
- 9
1
vote
1 answer
Access SKCameraNode from a different class using Swift
I have created an SKCameraNode in my GameScene class and have added buttons to it as SKSpriteNodes. I then set the GameScene camera to be the SKCameraNode.
I have another custom Class called Player of type SKNode. From this Class I need to access…

TazmanNZL
- 372
- 3
- 16
1
vote
0 answers
Check if SKNode touches another SKNode
I am writing a game where I move nodes through touch functionality. When I am finished moving the specific node to the new location, I want to check if the node I have moved is lying over another existing node.
I have tried with collision checking…

Pete
- 613
- 1
- 6
- 18
1
vote
0 answers
Detecting touches in nested/overlapping Sprites/Nodes
I currently have an SKNode that generates children SKLabelNodes inside it for a menu. Both are classes that I wrote, with
override func touchesBegan(touches: Set, withEvent event: UIEvent?)
and I attempt to detect what is being touched…

HowDoMagnetsWork
- 11
- 1
1
vote
1 answer
SpriteKit: Determine if point is inside a rotated node
I'm trying to determine if a point is inside a node that's been rotated. I've tried the following code in my scene:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
/* Called when a touch begins */
UITouch *touch = [touches…

Manool
- 11
- 1
- 1
1
vote
0 answers
How to get an SKNode's zRotation relative to its scene?
Is there some way to get a SKNode's zRotation relative to its scene rather than to its parent? Or even relative to any other SKNode?
Right now I'm doing this:
func rotationRelativeToSceneForNode(node: SKNode) -> CGFloat {
var nodeRotation =…

Ivens Denner
- 523
- 5
- 12
1
vote
1 answer
Swift weak variable behaviour difference?
I came across some old Swift code (badly written from when I was first playing with the language back in June) and I was curious why the function test fails, but test2 works?
fatal error: unexpectedly found nil while unwrapping an Optional…

fuzzygoat
- 26,573
- 48
- 165
- 294
1
vote
1 answer
Swift- SKEffectNode takes a while to appear
So I have a pause button in my game that when you press it, the scene gets paused, and everything but one SKNode (the pause menu) gets blurred out. I'm doing this by creating a SKEffectNode that has a filter, and adding everything but the pause menu…

Yoli Meydan
- 161
- 1
- 5
1
vote
1 answer
SceneKit: SKNode resolution on iOS
I am using a .dae file to create my SCNNode. The quality of my 3D object looks perfect when opening with the .dae file editor, or preview app, but it looks so poor on the SCNNode (screenshot's pixelated lines).
Does this issue have any solution or…

Pablo A.
- 2,042
- 1
- 17
- 27
1
vote
1 answer
Camera Movement Not Fast Enough
I currently am attempting to center a camera on a SKNode in SpriteKit.
In the update function I have the following:
override func update(currentTime: NSTimeInterval) {
if self.camera != nil {
self.camera!.position =…

Aaron
- 757
- 5
- 18
1
vote
2 answers
SKLabelNode.name target for setText
Question
How to target an SKLabelNode by name? to change it's text?
Example;
SKNode *node = [self childNodeWithName:string];
[node setText:value];
How does one achieve this? I cannot do it by targeting it's instance variable as I have multiple…

Daniel
- 285
- 3
- 12
1
vote
2 answers
How to translate SKPhysicsContact contactPoint into my SKSpriteNode position
I've spent too long on this. Someone has solved this already, please help.
Enemy fires on my ship. SKPhysicsContact takes over and I get contactPoint. I explode the fired missile at the contactPoint, in world coordinates. All good. Now I would like…

julius patta
- 78
- 1
- 8