Questions tagged [skcameranode]

38 questions
9
votes
1 answer

Swift: Agar.io-like smooth SKCameraNode movement?

If anyone here has played Agar.io before, you'll probably be familiar with the way the camera moves. It slides toward your mouse depending on the distance your mouse is from the center of the screen. I'm trying to recreate this movement using an…
MysteryPancake
  • 1,365
  • 1
  • 18
  • 47
3
votes
0 answers

SkCamera Node has ambiguous size?

I'm currently working on a Spritekit Game with a SKCameraNode allowing the player to look at a strategic map. I am trying to implement a HUD by adding child nodes to the SKCameraNode, but I have run into a problem concerning how the coordinates of…
Aleksandr
  • 533
  • 1
  • 4
  • 12
3
votes
2 answers

SpriteKit: how to smoothly animate SKCameraNode while tracking node but only after node moves Y pixels?

This question and others discuss how to track a node in SpriteKit using a SKCameraNode. However, our needs vary. Other solutions, such as updating the camera's position in update(_ currentTime: CFTimeInterval) of the SKScene, do not work because we…
Crashalot
  • 33,605
  • 61
  • 269
  • 439
3
votes
1 answer

SpriteKit: static background in the scene with moving SKCameraNode

My goal is to have a static node in the background of the SKScene. In this scene, I use SKCameraNode to pan around as needed. The background node has to be static because it presents the sky in far distance which is expected not to move. Problem: If…
damirstuhec
  • 6,069
  • 1
  • 22
  • 39
2
votes
0 answers

Parallax effect with SKCamera

I am making a 2D platform game (like Mario). I move the SKCamera to left and right with 2 buttons (left and right). The x and y coordinates of the 'Mario-spite' is the same a the x and y coordinates of the SKCamera. I move the SKCamera and also the…
Johan Kornet
  • 103
  • 11
2
votes
1 answer

Swift 3.0: SKSpriteNode as Button does not work when given a non-SKView parent?

There are already a few questions out there regarding how to make a button in SpriteKit such as Swift Spritekit Adding Button Programaticly and Setting up buttons in SKScene. Either way, the solution is to make an SKSpriteNode with a texture for…
SumNeuron
  • 4,850
  • 5
  • 39
  • 107
2
votes
1 answer

Smoothing out zoom with limits in Spritekit

I've been working on adding zooming functionality to my project via an SKCameraNode and a pinch recognizer. My camera node is overlooking the mainMap node that contains my game and I would like to have limited zoom capability. In my function handler…
Aleksandr
  • 533
  • 1
  • 4
  • 12
2
votes
2 answers

SKCameraNode.position didSet does not get fired when moved with an SKAction

I have a simple subclass of SKCameraNode that I called InteractiveCameraNode. For now it's very simple: I need things to happen when my camera's position changes. Here is what I did: class InteractiveCameraNode: SKCameraNode { // MARK: -…
BadgerBadger
  • 696
  • 3
  • 12
2
votes
2 answers

How can I make so a node is not affected by the SKCameraNode?

Ok so currently I have a camera coded into my project. I added my background to the game and it doesn't move currently. However, I want to add more things that aren't affected by the camera such as a ground. Here is my current code: …
Josh Schlabach
  • 401
  • 5
  • 17
2
votes
1 answer

SKCameraNode not centered

I'm working with Swift 3, Xcode and SpriteKit I have a SKCameraNode named cam, and I put a node at the camera's position to check it: var cam: SKCameraNode! let cameraNode = SKSpriteNode(imageNamed: "hx") override func didMove(to view: SKView) { …
Drakalex
  • 1,488
  • 3
  • 19
  • 39
2
votes
1 answer

What is the best way to zoom and deplace nodes?

I'm working with Swift 3, SpriteKit and Xcode. So I have a node named backgroundNode, and I attach every nodes of my game to this backgroundNode. Now I would like to be able to zoom on my game with a pinch gesture, and when I'm zoomed in to navigate…
Drakalex
  • 1,488
  • 3
  • 19
  • 39
2
votes
2 answers

Using SKCameraNode for an Universal App SWIFT

I develop an universal game using Sprite Kit Level editor on Xcode 8 beta 4. My scene in the level editor does 750x3334. In my scene I have a background image, the background image is adjusted to the scene size. Scene anchor point = (0,1) Top…
cmii
  • 3,556
  • 8
  • 38
  • 69
1
vote
2 answers

Math for zooming in and out of a SpriteKit scene

Using these as guides: SpriteKit pinch to zoom camera SpriteKit- How to zoom-in and zoom-out of an SKScene? I've implemented the following functions to zoom in and out of a SpriteKit scene, as well as the ability to incrementally zoom in and out of…
narner
  • 2,908
  • 3
  • 26
  • 63
1
vote
1 answer

SpriteKit camera stuttering when following player

I'm experiencing this lag or stutter in my game, and I'm thinking it could be due to the way I have the camera follow my player. Here is the code: func update(_ hp: CGPoint) { let camMove = SKAction.move(to: CGPoint(x: hp.x, y: hp.y), duration:…
Discoveringmypath
  • 1,049
  • 9
  • 23
1
vote
1 answer

Swift: Wrap / loop / repeat nodes outside camera bounds?

I'm making a game with a camera setup that could be compared to the one in Agar.io. It can go up, down, left and right. However, in Agar.io you're limited to the space of the map. If you run into a side of the map then you have to go back. However,…
MysteryPancake
  • 1,365
  • 1
  • 18
  • 47
1
2 3