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
How to get a child sprite position in the view
I am attempting to get the child sprites position in the view based on the answer here and this
for child in platformGroupNode.children {
CGPoint p = [child.superview convertPoint:child.center toNode:self.view ]
println(p)
}
However I am…

Yonkee
- 1,781
- 3
- 31
- 56
1
vote
1 answer
Swift - How to run 2 actions non-simultaneously (in linear mode) for two different SKNodes in the same function
I have a function in which I need to run 2 actions one after another.
e.g.
func foo()
{
..........
if someConditions
{
node1.runAction1
node2.runAction2
}
}
It seems that swift is running those actions…

Ady Năstase
- 249
- 2
- 9
1
vote
1 answer
How would I pause my background when my heroNode makes in contact with the enemyNode in Swift Spritekit?
I'm trying to pause my background when my hero node makes contact with the enemy. When I use this code I posted below the speed of the background doesn't stop it keeps going its normal speed. I tried declaring the "city" globally only but I get an…

newtocoding
- 109
- 10
1
vote
2 answers
Sprite kit (objective c) check texture of sprite node
i need to check if my sprite node texture is equal to name @"GoldDot".
i try the code
if ([red.texture isEqual:@"GoldDot"]) {
NSLog(@"gold!!!!");
}else{
}
please help

100tomer
- 137
- 1
- 10
1
vote
0 answers
Initializing GameScene.sks node causes error "Attemped to add nil node to parent"
I've seen a lot of these types of questions, but most of them were in Swift - also none of them seemed to have concrete answers. I am attempting to add a "worldNode" SKNode to a GameScene.sks file using the GUI editor. This node will be used as a…

Solsma Dev
- 481
- 6
- 22
1
vote
1 answer
Get and change radius size of Node - Sprite-Kit
I am using Swift and SpriteKit and I create a new circle (as a Node) like this
var circlePlayer = SKShapeNode(circleOfRadius: 10)
and I would like to access later on the radius of the circle in order to get its value or modify it (increase it by…

sachalondon
- 165
- 1
- 11
1
vote
0 answers
Swift: SKNode intersectsNode not working
The following code doesn't work as expected. For reason incomprehensible to me "monster intersect player" is never called. What's the matter here?
for monsterNode in self.children as [SKNode]{
if (monsterNode.name? ==…

user3673836
- 591
- 1
- 9
- 23
1
vote
1 answer
Swift: typecasting in a for loop
I'm a noobie in Swift. I'm trying to iterate over SKNodeTree and check if there are scary monster Nodes here. However I cannot figure out how to typecase the for loop. I have understood that this would be possible with "as" clause.
By the way, is…

user3673836
- 591
- 1
- 9
- 23
1
vote
0 answers
Shooting a projectile in spritekit
I am looking to shoot a SKSpritenode (a cannonball) from a another Sprite node (enemy ship).
The cannonball should travel directly down toward bottom of screen from the enemy ship node.
I can't seem to get positioning right, cannonball seems to…

dancingbush
- 2,131
- 5
- 30
- 66
1
vote
1 answer
'SKNode?' does not have a member named 'position'
What am I doing wrong? I can't seem to figure this out. I have tried putting an exclamation mark behind: var thisBlock = self.childNodeWithName(block),
this gives me a new error saying. type () does not confirm to protocol 'BooleanType'.
func…

Jerom Kok
- 11
- 1
1
vote
1 answer
SKSpriteKit. Can the SKScene be used as a physical body to pin an SKNode?
I want to fix an SKNode (the node has a physics body) in space by pinning it to the SKScene. So it can participate in the physics simulation - collide, spin, etc. But not move. Is this allowable? Is there a better way to fix an physical node in…

dugla
- 12,774
- 26
- 88
- 136
1
vote
2 answers
SpriteKit childNodeWithName can't find existing node
I have this code in SKScene:
override func touchesBegan(touches: NSSet!, withEvent event: UIEvent!) {
var touch: AnyObject = touches.anyObject()
var point = getPoint(touch.locationInNode(self))
var name = NSStringFromCGPoint(point)
…

Valeriy
- 785
- 2
- 10
- 28
1
vote
1 answer
SKAction not working properly
I have a sequence of SKActions that I would like to play but they do not play properly. The eye only closes and never opens again. I have no clue why this is occurring but maybe you do! Help is appreciated, thank you.
-(void)blink {
SKAction…

BruceTheGoose
- 63
- 1
- 10
1
vote
2 answers
SKAction: how to generate a random delay in generation of nodes
I use the following piece of code to generate SKNodes periodically. Is there a way to make the period of generation of these SKNodes random. Specifically, how do I make the "delayFish" in the following code an action with a random delay?
[self…

RawMean
- 8,374
- 6
- 55
- 82
1
vote
1 answer
Detecting when SKEmitterNode particle makes contact with another SKNode
Does anyone know how I can detect when an SKEmitterNode particle makes contact with a SKNode in the SKScene?
I want to apply a little force to the SKNode when a particle makes contact with it for a 2D game I'm creating.

SamoanProgrammer
- 954
- 4
- 13
- 27