How to letterbox SpriteKit games for iPhone X?

I have a game developed in SpriteKit. Currently the game covers the whole screen on iPhone X. I want to letterbox it so there is black space at top and bottom when in portrait mode, and at left, right and bottom when in landscape mode. Basically, I...
more »

2017-11-28 02:11 (1) Answers

Matchmaking and Swift

I'm working with a multiplayer game using Swift, SpriteKit and Firebase. It's the first time I'm using multiplayer and GameKit so I don't get the concept of matchmaking. I read Apple Documentation but honestly it's not clear, it tells me what real-...
more »

2017-11-27 19:11 (0) Answers

Keeping track of SKNodes for a category

I have a function that adds enemies to my scene that get called by an timing interval How can I keep track of the number of enemies on the Scene to limit the amount of enemies I have in each level? **In my update function ** CFTimeInterval timeS...
more »

2017-11-15 09:11 (1) Answers

SpriteKit linearDamping - maximum?

Note that Apple's doco asserts https://developer.apple.com/documentation/spritekit/skphysicsbody/1519796-lineardamping This property is used to simulate fluid or air friction forces on the body. The property must be a value between 0.0 and 1.0. ...
more »

2017-11-12 21:11 (0) Answers

SpriteKit, put a process on another core?

Imagine in your class NattyScene: SKScene { you have perhaps a custom Field for the nodes, or something else that happens every frame. Now imagine you have some calculation, a nice example might be center of gravity ... var globalCOG: CGPoint fu...
more »

2017-11-09 00:11 (1) Answers

How are co-ordinates calculated in Swift

I've been trying to get the following code to display a rectangle at the bottom of an iPhone simulator in landscape mode: let size = CGSize(width: 100, height: 10) let myRect = SKShapeNode(rectOf: size) myRect.position = CGPoint(x:self.frame.midX, ...
more »

2017-11-06 10:11 (1) Answers

SpriteKit Battery/Energy Drain

I have been developing a game for a little while now and have come to realize that my app quickly drains the device battery. I have measured the energy drain through XCode instruments and it is generally in the 17/20 range. I have a handful of backgr...
more »

2017-11-03 20:11 (0) Answers

SKReferenceNode issue in iOS 11

I have found a strange issue starting with iOS 11 where my app will not update sprites on my SKReferenceNode. Basically, I have an "overlay" node (an SKS file that I use for multiple scenes) that has a header and footer. In the header, there is a sco...
more »

2017-10-23 15:10 (1) Answers

Stop processing SKShader

I'm new to shaders, but as I understand, they work in realtime. If I have a shader that needs to change the texture once, the shader works all the time, but nothing changes on the screen, because the texture changes according to the same algorithm. ...
more »

2017-10-19 16:10 (0) Answers

Xcode Swift SKAction.follow start point

I am trying to make a spaceship orbit around a planet. I am currently doing let playerPos = player.position let planetPos = planet.position let radius = playerPos.x - planetPos.x let rect = CGRect(x: planetPos.x - radius, y: planetPos.y - radius, ...
more »

2017-10-17 22:10 (2) Answers

Spritekit actions doesnt't work on all devices

I have spritekit scene with element that has actions: https://scr.hu/dXryae https://scr.hu/Gw3Ra5 I'm loading this scene, get the Overlay element and put every child of it in main scene of game. Everything were working fine till I tried to add som...
more »

2017-10-09 16:10 (1) Answers

SpriteKit animation stops unexpectedly

I'm trying to debug a very strange behaviour of SpriteKit animation. It's quite easy to reproduce: Create a new Game project in Xcode leaving all the options unchanged. Open GameScene.swift and change line #23 from label.run(SKAction.fadeIn(withDur...
more »

2017-10-09 00:10 (1) Answers

SKTileMap getting Values from GKNoiseMap

ive been following the Apple Docs on GKNoiseMaps and i managed to get an image to spawn and it looks really good using this code here class GameScene: SKScene { class Noise: GKNoise { var NoiseSource = GKPerlinNoiseSource(frequency: 0.05, oc...
more »

2017-10-07 10:10 (1) Answers

How to make an ArrayList of enemy objects in Swift

I’m trying to code a game in swift and I want to be able to keep track of enemy position, Heath, and such. Like in Java it’s as easy as declaring an array list of type, say, enemy and then filling it with a forloop or when ever I want to add an e...
more »

2017-10-05 16:10 (1) Answers

how to access entity from code - gameplay kit

I have a node I added in the scene. Also in the scene I give it a component to bounce. The component looks like this: class BounceComponent: GKComponent, ComponentSetupProt { var bounce: SKAction? var node: SKSpriteNode? @GKInspectable var diff: C...
more »

2017-09-30 03:09 (1) Answers

SKAction wait interval NOT consistent

I have a function that creates SpriteNode copies and move each copy along a rectangle path at a specified interval. I have a problem with this interval that the action is executed at inconsistent interval making odd gaps between sprite nodes while a...
more »

2017-09-23 07:09 (1) Answers

Move object while holding button in Swift

I have a little Space Invaders game and I added two buttons leftButton and rightButton and I want the ship to move as long as one of the buttons is touched AND HELD in the proper direction. I made it move in the right direction but I have to tap the...
more »

2017-09-20 18:09 (2) Answers

Spritekit Changing Gravity

I've been trying to be able to alter gravity by using override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { self.physicsWorld.gravity = CGVector(dx: 0, dy: 0) } but that doesn't seem to change the gravity at all. When ...
more »

2017-09-17 02:09 (1) Answers

swift animate spritekit with damping effect

I've been searching on the internet for several days, I didn't find what I'm looking for. I'm working on an iOS game and I would like to move some sprites using usingSpringWithDamping (to have some rubber effect when moving my sprites). I have found...
more »

2017-09-07 21:09 (2) Answers