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
1 answer
Value of type 'SKNode' has no member 'texture'. But it does
I created this SpriteKitNode:
let examp = examps[examps.count-1] // examps is a global array with SKNodes inside of it
But when I try to change its texture I receive this error:
examp.texture = SKTexture(imageNamed: "examp2")
Value of type…

Go Fast
- 23
- 5
1
vote
2 answers
Remove SKAction and restore node state
Desired behavior is: when an action is removed from a node (with removeAction(forKey:) for instance) it stops to animate and all the changes caused by action are discarded, so the node returns back to pervious state. In other words, I want to…

kelin
- 11,323
- 6
- 67
- 104
1
vote
1 answer
How to add node relative to tracked image position with ARKit?
When an image is detected, I add a node in front of it.
Image - what i need garantee
The node is this picture and in relation to this picture I add other nodes, one above (1) of the picture and another next (2). Node 1 always gets in the correct…

Bruna machado costa
- 15
- 5
1
vote
1 answer
Run SKemitter Once?
Is there a way to only run a SKemitter one time? I have a explosion when it is colliding with another node. The problem is that the explosion happens multiple times since it hits multiple times. How would I go about only running it once time?

Matt Cantrelle
- 151
- 1
- 8
1
vote
2 answers
Generating new nodes causing frame drop [SpriteKit]
I'm trying to generate new nodes in scene
func generateNewPlatform(inScene: SKScene) {
for _ in 0...25 {
let xPosition = randomXPosition()
let yPosition = randomYPosition()
let platform = Platform.create(
…

k0le
- 40
- 8
1
vote
0 answers
Interacting/Touching SKNode inside SCNPlane in ARKit does not work
I am trying to create a button on an ARKit project, so I created a plane on my sceneView on an ARKit project, to which I assigned a SKScene containing a button as material.
The button is a custom SKNode that detects touches to change color and call…

Jacobo Koenig
- 11,728
- 9
- 40
- 75
1
vote
1 answer
Sprite position not updating to where it is being moved to
Since I am working in spritekit, I decided not to use UIScrollview because from what I could tell it is difficult to implement. Instead, based on research online I decided to create an SKNode and add all of my sprites as children of the SKNode. From…

joey
- 49
- 7
1
vote
1 answer
Trouble converting between coordinate spaces in SpriteKit
I am trying to get a SKShapeNode to follow a UITouch
My problem is that the location of the UITouch is relative to the bottom-left corner of the screen and the position of the SKShapeNode is relative to the location I gave it when I created it, the…

Davis Mariotti
- 574
- 1
- 4
- 23
1
vote
1 answer
How to add a sprite from another class on the gameScene
can anyone explain how to add a node to the gameScene please.
I subclassed my Boss class but i dont know how i can display my Boss1 on the GameScene
class Boss: GameScene {
var gameScene : GameScene!
var Boss1 = SKSpriteNode(imageNamed:…

DamsoJilo
- 31
- 6
1
vote
1 answer
SpriteKit simulation speed / applyImpluse speed
I'm in the process of learning sprite kit and decided a catapult style game would be a good project to start with.
I am launching a projectile by using physicsBody?.applyImpulse(CGVector(dx: strength * dx, dy: strength * dy)) and this all works…

David
- 11
- 1
1
vote
2 answers
Modify property on SKNode while moving
I have a subclass of SKNode that acts as my "creature". These move about the scene automatically using SKActions. I'm interested in modifying (decreasing) an 'energy' property (Int) as the creature moves.
The creature isn't guaranteed to move the…

Brad Root
- 483
- 5
- 14
1
vote
2 answers
How to control the speed of nodes in SpriteKit
I have a bunch of objects (SKNode) starting from the top of the screen 'falling' to the bottom via SKAction.move(to:duration:) and node.run(moveAction). In addition I have node in the center of the screen with its own physics body that can be…

CoderNinja
- 571
- 3
- 7
- 20
1
vote
1 answer
ObjectIdentifier needed for Swift equality?
We have multiple instances of a custom Swift class, which inherits from SKSpriteNode, and were able to execute the following code (grossly simplified for this question) correctly:
let instance1 = CustomClass()
let instance2 = CustomClass()
let…

Crashalot
- 33,605
- 61
- 269
- 439
1
vote
1 answer
Adding multiple instances of objects spritekit swift 3
I am trying to add multiple instances of my object (bullet) so the player can shoot the bullet and then shoot another bullet. I am using the following code but it is giving me a thread 1 signal sigbart error. Can someone please explain whats wrong…

c3pNoah
- 65
- 1
- 12
1
vote
1 answer
SKSpriteKitNode's rotation does not match GKAgent2D's rotation
Hello I am trying to understand basic gameplay kit. But seem to run into trouble with matching the rotation of my agent to that of the spritekitnode on which it is supposed to act. I am using the spaceship which comes with the new game template in…

nata11
- 109
- 1
- 8