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

Ideas on how to manage movement of SKNode related to other, moving down but maintaining the same alignment with the other SKNode

i'm new in the development of swift ios game using spirtekit and i need help. I want to develop a vertical 2d endless run, where with a swipe you are able to move the player in direction and if there is an obstacle, it is created in a position…
andrea
  • 47
  • 1
  • 12
1
vote
3 answers

Change texture of a SKNode once it is placed?

Note: I have looked at previous SO questions on this subject. I have tried the methods suggested to no avail. The suggestion to change the texture of the node is already implemented, and as I have a "texture" variable for the SKNode I want to…
Student-LTB
  • 103
  • 8
1
vote
1 answer

SKShpapeNode position and touch.location difference

I was learning about SKNodes in Swift and have encountered a problem. App was supposed to be very simple: touching screen and getting node to appear in the touched position. I don't know why but the rectangle keeps showing in different place on the…
mikro098
  • 2,173
  • 2
  • 32
  • 48
1
vote
1 answer

Swift-Making an SKNode simply "move forward" on an angle

I've already asked this question in a different way here; Swift-Setting a physics body velocity by angle but the three attempts to answer it were unfortunately not exactly what I'm looking for, although I'm grateful for what they taught me anyway. I…
1
vote
0 answers

SKNodes with SKPhysicsBody under SKAction move inaccuracy

I have two SKNode with physics (one under another): - (SKNode*) newNode { SKShapeNode *node = [SKShapeNode shapeNodeWithCircleOfRadius:60]; node.strokeColor = [SKColor clearColor]; node.fillColor = [SKColor greenColor]; …
1
vote
2 answers

Swift-Setting a physics body velocity by angle

I was wondering if it was at all possible to make an SKNode move forward in a particular direction, but with only one factor. I'm aware of both applying an impulse and setting the velocity of a physics body, but they're both determined by two…
1
vote
1 answer

Spritekit move camera only if not dragging from sprite

In a game I'm building a user is able to move the camera around by dragging around the screen similar to a scrollview. This is all handled in the main scene file by the touchesBegan and touchesMoved method. However I also want the ability for a user…
TommyBs
  • 9,354
  • 4
  • 34
  • 65
1
vote
0 answers

nested SKNodes in spritekit?

I would like to make a hollow box, with a number that floats in the middle of it. the box and the number inside should behave according to physics as if the number were attached by springs to all 4 corners (or sides) equally. In my code here, that's…
Dave Kliman
  • 441
  • 4
  • 17
1
vote
0 answers

Swift, node moving alone

I am trying to use SKNode in overlaySKScene in a SCNView. But when I set the property isPlaying of the SCNView to true, my SKNodes are just going down. This is my code in viewDidLoad: sceneView.isPlaying = true; sceneView.loops =…
gfitas
  • 45
  • 7
1
vote
2 answers

Add block between two points. SpriteKit

I am trying to add a SKNode between two points like picture below. What I have: I count the distance between those two points with this code (works fine): func distanceCount(_ point: CGPoint) -> CGFloat { return abs(CGFloat(hypotf(Float(point.x…
0ndre_
  • 3,577
  • 6
  • 26
  • 44
1
vote
2 answers

Present GameScene from UIViewController

I want to present a GameScene with GameViewController from my ViewController. I tried: // let GameControllerA2 = GameViewController() // let transition = CATransition() // transition.duration = 0.5 //…
user6083214
  • 63
  • 1
  • 8
1
vote
2 answers

Grouping SKNode physics bodies?

I have 10 square nodes with square physics bodies in a row. How can I best merge these physics bodies to create a single skphysicsbody? The reason I need to do this is that a square object traveling on top of the square row "trips" at random. If I…
Stefan Kendall
  • 66,414
  • 68
  • 253
  • 406
1
vote
1 answer

Subclassing SKNode, or SKSpriteNode for complex buttons

I'm making complex buttons with various states and animations between states, and looping "attract" animations. Due to the nature of the shadows, highlights, glows and internal visual changes the buttons are quite complex. Each button has several…
Confused
  • 6,048
  • 6
  • 34
  • 75
1
vote
2 answers

How to keep node from moving off of (outside of) another node

I have a few square-shaped nodes (like floor tiles) going along the screen and I'd like to restrict my player (P) node to moving within these nodes. --------------------------------- | | P | | | | | | | <- Want no movement allowed…
iank
  • 800
  • 3
  • 10
  • 32
1
vote
1 answer

Move a SKNode around a circle

i am moving my sknode around a circle created with this code: circleDiameter = 300; pathCenterPoint = CGPointMake(self.position.x - circleDiameter/2, self.position.y - circleDiameter/2); UIBezierPath *circlePath = [UIBezierPath…