Questions tagged [sknode]

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.

331 questions
1
vote
1 answer

GKScene and SKNode.entity

I've been updating a SpriteKit/GameplayKit project for Xcode 8 and the new Scene Editor which allows adding Entity-Component information to a scene. I've been to move my entity code into the scene, but I'm having trouble accessing the entity from…
Duncan Oliver
  • 39
  • 1
  • 9
1
vote
1 answer

How to add 1 point every time SKNode is touched

I created a game involving falling balls. Every time the player taps a ball, they're supposed to get a point. I set up the score label, but it just stays at 0. Is there something wrong with my code? I use a GameElements.swift file as an extension.…
DrPepperGrad
  • 361
  • 1
  • 4
  • 17
1
vote
1 answer

SKNode comparable to NSMutableArray, GCD, enumeration

My question, is very simple I think, but I can't find any direct info to confirm or deny. My question is: When enumeration thru SKNodes, should they be treated delicately using: SKNode *someTreeNode; NSArray *someArray = [someTreeNode children]; …
1
vote
1 answer

Updating SKNodes outside update() of scene

I was quite surprised that the update method in the SKScene class isn't actually inherited from SKNode. To me, it seems logical for all SKNodes to be able to update themselves (for instance to remove itself from the scene when it's no longer on…
Youssef Moawad
  • 2,846
  • 5
  • 28
  • 50
1
vote
1 answer

Hide node in SKScene in interface builder

I have several SKScene done in interface builder in which I have positioned several sprites within the part of the SKScene that is visible on the screen I want some sprites to only appear later so I start to hide them at the beginning in the…
Jonah Begood
  • 317
  • 2
  • 14
1
vote
3 answers

Cannot cast SKNode to subclass of SKNode

I am returning an SKNode from one function and I need to cast it to a custom SKNode. I get the error Cannot assign value ofSKNodeto typeGroundNode. If I force cast, it compiles, but fails at runtime. What am I missing? // Custom node class class…
Siriss
  • 3,737
  • 4
  • 32
  • 65
1
vote
1 answer

Unable to access child properties of SKNode

I've got a for loop that sorts through children of a SKNode, and for some reason I can only access the child's properties of a SKNode and not SKSpriteNode properties such as size after casting it. for tile in map.children where tile is SKSpriteNode…
1
vote
1 answer

how to add a SKnode on a loop that can be toggled on and off

I am creating a game and i keep getting this error for my bullet spawn method linked with a joystick. I want to repetitively spawn the bullet node while the joystick is active. Here is how i am creating a firing method class GameScene: SKScene,…
gkolman
  • 189
  • 10
1
vote
1 answer

Swift + SpriteKit - Button is clickable even when not visible

I seem to be having problems with one of the Nodes on my scene. I have a button: func createAttackButton() { attackButton.zPosition = 1 attackButton.anchorPoint = CGPointZero attackButton.position = CGPointMake(20, 20) …
JamesG
  • 1,552
  • 8
  • 39
  • 86
1
vote
1 answer

SpriteKit world wrong positioning

I'm trying to make my first game using SpriteKit & Swift. I think I understood the concept of World SKNode, but I can't make it work properly. I add world:SKNode as a child to the GameScene. Then I add 9 child SKSpriteNodes (400px X 400px from…
Nikolay Pryahin
  • 377
  • 5
  • 19
1
vote
2 answers

How to present a view on top of SKScene?

I know there is many question out there on the same topic but still I didn't get any idea or solution to make it work. How do I implement a small view on top of a scene with options as shown in image?
Pruthvi Hariharan
  • 551
  • 1
  • 6
  • 23
1
vote
1 answer

Stop Action in SpriteKit with swift

In a tetris-like game, I am trying to use actions to move the Shapes down and then when the next shape is called, it will stop the previous shape from moving, so that they arent both moving. I have tried to use removeAllActions and…
MathCoder
  • 11
  • 4
1
vote
3 answers

SpriteKit static HUD with camera on player

My issue is the HUD isn't staying in the same position but moving with the camera also. I'm trying to create a version of Sokoban using swift_boxxle code found on Github, I've added a new SKNode called mazeWorld, a camera node and a HUD node. var…
Alex Hedley
  • 776
  • 10
  • 24
1
vote
1 answer

How to access objects of SKSpriteNode subclass when moving them (Swift)

I am confused with the objects of my class Card that is the subclass of SKSpriteNode. How do I get access to these objects when a user move them. So far I can only access SKNode objects overriding touchesEnded function. override func…
David_Zizu
  • 1,009
  • 1
  • 11
  • 18
1
vote
1 answer

How to rotate a SKNode without changing its position?

I have a SKNode which consists of 4 SKSpriteNodesthat make up a square shape (I hope I'm wording it right). Each side of the square has a different color, and I'm trying to rotate the whole square wihout chaning its position. The way I'm trying is…
Sharukh
  • 199
  • 1
  • 1
  • 12