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
Getting userData from SKNode array in for loop
I am having some trouble getting the userData values from my object. I know the userData is being set for the objects because else where in my code I am able to access it without any problems.
I created a SKNode *column3 to hold all the buttons that…

the_pantless_coder
- 2,297
- 1
- 17
- 30
1
vote
1 answer
Not working right, start and end positon
I'm trying to graph some trigonometric functions on an SKScene.. I'm using an SKShapeNode for each point in the screen so when it reaches the left side I remove if from the parent.
The problem is that, for some reason it only draws on a portion of…

GKTon
- 61
- 5
1
vote
1 answer
How to remove a child SKSpritenode from SKNode?
i will explain a part of my code. I have Spritenodes (images) who are moving down on the screen.
SKTexture* Squaretexture = [SKTexture textureWithImageNamed:@"squaregreen"];
SquareTexture.filteringMode = SKTextureFilteringNearest;
Square =…

Mehmet63
- 81
- 1
- 8
1
vote
1 answer
Re-defining SKNode means I have to re-add the node as a child?
I have a case in my code where it seems like I have to re-add a child node if I redefine what it's pointing to but I don't quite understand why.
For example:
_worldNode = [SKNode node];
_childNode = [SKNode node]; //set childNode to point to a node…

HHHH
- 1,197
- 2
- 16
- 28
1
vote
2 answers
sprite kit - Get notified when a node have been added to a scene
I have a subclass of SKNode whose I want to get notified when they are added to a scene.
Knowing that SKNode have a property called scene, I tried to use KVO but for some reason it's not working.
- (id)init
{
self = [super init];
if (self)
…

Yaman
- 3,949
- 4
- 38
- 60
1
vote
2 answers
How can you detect if SKShapeNode is touched?
I created a sknodeshape. How can I detect if the shape I made was touched(clicked)?
Here is the code: (I solved it already)
//metung_babi is the name of the SKShapeNode
UITouch *touch = [touches anyObject];
CGPoint nokarin = [touch…

East Bay Ray
- 81
- 1
- 9
1
vote
1 answer
Check when SKShapeNode is clicked
So I generated an SKShapeNode, and need to know when that node is clicked. I do so by calling:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint positionInScene = [touch…

Dan
- 345
- 2
- 17
1
vote
2 answers
Sprite Kit setting a nodes angle (not rotate)
Okay so I have a game that the player(space ship) is trying to go around a planet, but if it gets to close the player's space ship is turned to the planet.
So I am trying to use:
float dx = [_player position].x - [planetNodes[i] position].x;
float…

user3148575
- 11
- 1
- 4
1
vote
0 answers
UIPinchGestureRecognizer trouble
Ok, i've read a few posts on this one (ex. UIImageView Gestures (Zoom, Rotate) Question) but I can't seem to fix my problem.
I have the following setup: an SKScene, an SKNode _backgroundLayer and 9 SKSpriteNodes that are tiles that make up the…

μ4ρκ05
- 585
- 2
- 5
- 16
1
vote
1 answer
Tiled background: Not all sprites appear
I am trying to create a scene that will have a tiled background on top of which there will exist the available levels the user can select and he/she will be able to pan the background in order to view all the levels.
So, as was suggested in the iOS…

μ4ρκ05
- 585
- 2
- 5
- 16
1
vote
1 answer
Why does Sprite Kit SKNode expose zRotation, xScale and yScale instead of simply a transform?
Sprite Kit relies on zRotation, xScale and yScale instead of simply a transform property. Is it because Apple needs the rotation and scale values to compute physics with higher performance?
Or why else would they not simply expose a transform…

openfrog
- 40,201
- 65
- 225
- 373
1
vote
2 answers
SpriteKit Physics: Ignore when on different z plane
With SpriteKit, is it possible to have two nodes that collide with one another, but then when another node is introduced, have how the physics works change?
For example, consider the following 3 nodes:
- Object
- Object_Hole
- Player
So, a scene…

Joshua
- 197
- 1
- 10
0
votes
0 answers
Adding a Mac trackpad scroll gesture to a SKScene
To scroll a SKNode (called scroller) within a SKScene (called menuScene), I'm doing the following, which works perfectly but I'm not sure if it's the correct way to achieve this.
Within the NSViewController class, I'm overriding the scrollWheel…

Mateus
- 357
- 1
- 4
- 14
0
votes
0 answers
Adding SKNodes into a ScrollView?
On Android, I've previously used CCScrollView (part of Cocos2D-X) to add nodes to a scrollable container, with all the extras like the elastic bounce, scrollbars, swipe gestures, etc.
But I can't work out how to do this in Xcode. I know there's…

Mateus
- 357
- 1
- 4
- 14
0
votes
1 answer
SKNode not updating when text changes
I have an SKNode which contains 2 sub nodes (a sprite node w/an image and an SKLabelNode above the image which prints the number of available units).
Previously, after each time the USER 'spent' a unit the counters would update by removing the…

Mercutio
- 1,152
- 1
- 14
- 33