13,218 questions
1
vote
1
answer
76
views
SpriteKit dragging a node with a SKPhysicsJointSpring is there a way to get the spring to track its anchor point tightly but damp rapidly?
A significant mechanic of a project I am working on is going to involve dragging objects with your fingers and having the object being dragged interact properly with physics, pushing other objects ...
2
votes
1
answer
260
views
3D positioned SpriteKit content inside RealityKit (non-AR)
I have an ARView, configured with ARView.CameraMode.nonAR (a virtual camera without real-world data), and I want to use ARSKView to render 2D SpriteKit content positioned in 3D space.
According to the ...
0
votes
1
answer
133
views
How to manage interaction in 2D and 3D within a RealityKit game
My game is utilising RealityKit to render a lot of 3D content. In the foreground I want to place a SpriteKit HUD that will contain buttons, and at times, complete overlays of the 3D content.
Right ...
1
vote
0
answers
45
views
Why are some SKView SpriteNodes moving jerkily with motionManager
I am working on an Xcode app that uses a Collection View Controller to display images of various animals. When one of the images is touched a GameView (SKView) opens. Each GameView has balls(sprites)...
0
votes
1
answer
39
views
tvOS SpriteKit: focusBehavior not working for my SKNodes despite setting focusBehavior to .focusable
I’m developing a tvOS game using SpriteKit and trying to make three SKShapeNodes focusable by setting their focusBehavior = .focusable. However, when testing on the Apple TV, the nodes are not ...
0
votes
0
answers
67
views
Accessing a SpriteKit Scene function from the parent SwiftUI view
I have a SKScene class called GameScene that is embedded in the GameView of my SwiftUI app. The SKScene is for a simple solitaire card game. When the game is over, I'd like the user to be able to hit ...
0
votes
0
answers
45
views
SwiftUI: SpriteKit Scene overflows screen when called
I am new to iOS and am porting a simple card game from Android. I'm trying to call a SpriteKit scene from my SwiftUI app. There are many useful posts that show how to do this, and I followed those ...
0
votes
0
answers
45
views
Spritekit: Why is my coordinator value nil when trying to navigate from my GameScene back to my home scene?
I'm new to iOS/Swift/Spritekit and am in the process of migrating a simple solitaire-style card game from Android. At present, I have two scenes:
LauncherScene, which is the home page for the app, ...
0
votes
1
answer
56
views
How do I prevent this code from sometimes ignoring my TouchesEnded handling?
I wrote a teensy app in Swift/SpriteKit/iOS for a button that turns a color when pressed.
It works fairly well except for one thing: If I touch the button in a certain fashion -- a quick half-swipe, ...
0
votes
1
answer
39
views
Spritekit: Implementing a double jump
I'm trying to make a running and jumping game where I want the sprite to be able to do one double jump.
The problem is that when I click the button a second time while the ninja is in the air, it ...
0
votes
2
answers
86
views
Animating dashes sequentially over a spline path in SpriteKit: How can I fix the gaps that appear on the straight sections?
I've created a SpriteNode subclass which is instantiated in the scene as a spline, and then I call the function .animateDottedPath().
I expect the dashes to animate over 5 seconds along the original ...
0
votes
0
answers
42
views
How do i fix a logic error meaning that an incorrect piece is moved in my spritekit game?
I am making a basic chess game in Swift with Spritekit:
func moveSelectedPiece(to newPosition: (Int, Int)) {
guard let pieceToMove = selectedPiece else { return }
// Calculate the ...
0
votes
0
answers
43
views
Lag between SKAction and SKAudioNode when SKScene is paused and resumed
Overview
In my SKScene, I have a SKAudioNode playing an audio file, declared as follows:
var backgroundMusic: SKAudioNode?
and initialized like this:
guard let musicURL = Bundle.main.url(...
0
votes
1
answer
42
views
SpriteKit Beginner: Mouse Node Not Moving to Random Locations
I’m a beginner playing around with SpriteKit, and I created a file called GameScene. It contains only one node called mouse. My goal is to animate the mouse and move it to random locations when the ...
2
votes
0
answers
88
views
Map does not load into the game
I'm currently creating a JRPG-like game in swift, but I have been stuck in implementing a tile map made thanks to spriteKit.
The problem is that the code can't load the map I made.
As I mentioned ...
0
votes
0
answers
44
views
iPhone SpriteKit rotation and zooming
I am new to SpriteKit, and I am trying to practice by making a simple 2D game. I've gotten so far as to have my map displayed on the screen, and cropped to only fill about 1/3 of the screen (so that I ...
0
votes
0
answers
37
views
GCVirtualController triggers didMove twice
New iOS person here..
Trying to incorporate GCVirtualController into my test code.
When I do, I see didMove getting called twice, thus causing lots of down-stream problems. As soon as I comment out ...
0
votes
0
answers
52
views
why is my SpriteKit collision detection not working properly?
I am making a SpriteKit platformer game and I am trying to get the collision detection working. so far I have written this code to detect when the player hits a tiles physics body:
func didBegin(_ ...
1
vote
0
answers
83
views
SpriteKit: SKTileMap leaks with `SKTexture(rect: CGRect)` usage
I am facing an issue that I am not able to resolve.
I have been able to create a demo project that demonstrates the issue, which I hope enables you to have a look as well and hopefully find a way to ...
0
votes
1
answer
33
views
SKLabelNode keeps jumping back and forth when displaying different numbers with equal number of digits
I'm trying to display a right-aligned timecode in my game. I had expected that digits would all have the same width, but this doesn't seem to be the case in SpriteKit, even though it seems to be the ...
0
votes
0
answers
28
views
SKSpriteNode will have some wrong change when the SKCameraNode Scale to High level
I am making a game like ColorByNumber, i ran into a tricky problem during development.
There are many SKSpriteNode in the GameScene, many blocks have many spacing.
When the SKCameraNode scale to ...
0
votes
0
answers
108
views
How to set SCNTechnique for SK3DNode
I am following some sample code (https://github.com/laanlabs/SCNTechniqueGlow) to add border to a 3d model using SCNTechnique. The code sets the technique to SCNView:
scnView.technique = technique
...
1
vote
1
answer
81
views
How do I stop a node as it is moving around a UIBezierPath and then restart the moving from where it stopped?
See Apple DTS' solution at the bottom of this Post ...
I have an oval UIBezierPath with a moving SKSpriteNode,
I stop its motion and record the stopped position. I then restart this motion and want it ...
0
votes
1
answer
37
views
SK3DNode unable to set scene's background color
I have this minimum reproducible code:
class GameViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
if let view = self.view as! SKView? {
...
0
votes
1
answer
49
views
SK3DNode taking up the whole screen despite the frame
I have the following minimum reproducible code:
class GameViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
if let view = self.view as! SKView? {
...
2
votes
1
answer
218
views
Call to main actor-isolated instance method 'run' in a synchronous non-isolated context
With a couple of other developers we have been busy with migrating our SpriteKit games and frameworks to Swift 6.
There is one issue we are unable to resolve, and this involves the interaction between ...
0
votes
0
answers
100
views
SK3DNode's hitTest function not finding the right SCNNode
I have this minimum repro code:
import SpriteKit
import GameplayKit
class MyGameScene3D: SCNScene {
weak var node3D: MyNode3D!
override init() {
super.init()
background....
0
votes
1
answer
74
views
adding snow effect to game scene with SpriteKit
I'm trying to add snow effect to my game scene by using SKEmitterNode. Since the game scene is quite large (25600 x 32000 pixels), I ended up adding the particle effects to the scene camera node. It ...
0
votes
0
answers
180
views
Metal Shader in SpriteKit
I am trying to render a red square using a Metal shader in SpriteKit. Instead I get a white square based on the color I supply when instantiating the SKSpriteNode. Using a default constructor and ...
2
votes
1
answer
130
views
Should I use `overlaySKScene` or `SK3DNode` when mixing SceneKit and SpriteKit?
I am making a 3D game but would like to reuse some of the components in my existing 2D games (e.g. the pop-up paused window). The top and bottom region where I display menu items are also be 2D. The ...
0
votes
1
answer
41
views
Meaning of calling SKNode.run multiple times
I am aware that SpriteKit supports compound actions that run in parallel, sequence, etc., and are added to an SKNode with via a single call to SKNode.run
What is however, the meaning of multiple, ...
0
votes
0
answers
46
views
SpriteKit: Increasing camera scale causes jagged edges
I have a scene (code below) in which some nodes should always visually appear to have the same size in the viewport. To achieve this I scale them in sync with the cameraScale. The problem that I am ...
1
vote
1
answer
311
views
Crash when preloading SKTextureAtlas in Swift 6
I have the following code:
import UIKit
import SpriteKit
class ViewController: UIViewController {
let textureAtlas: SKTextureAtlas
required init?(coder: NSCoder) {
textureAtlas = ...
1
vote
1
answer
76
views
Focusing an SKNode
I have the following code that builds and runs in a simulator in tvOS 17.5. I am trying to navigate focus between the two SKNodes inside the GameScene that is an SKScene. I am unable to have any of ...
0
votes
0
answers
48
views
Angular damping being applied to SpriteKit nodes despite setting value to zero
I have implemented a simple pendulum in SpriteKit that I want to continue swinging forever. I've set the angularDamping of all of my physics bodies to 0, but the pendulum still slows down (eventually ...
0
votes
0
answers
64
views
SKAction completion closure error: Escaping closure captures 'inout' parameter
I'm trying to call a function that takes in an Array as a reference
spill(pool: &objectPool)
And the function will make the array pops its first element to run some animations. Once the animation ...
1
vote
0
answers
96
views
How do I integrate Game Center & Leaderboards in a SpriteKit game?
I am very new to developing IOS games, but have published my first game into the appstore (it was just a very simple dice game like yhatzee using SpriteKit and it has a high-score saved by using ...
0
votes
1
answer
88
views
SwiftUI not setting a transparent background
I am trying to set a transparent background in my gamescene so when it is displayed in gameview a different background is shown.
here is my gamescene code:
class Gamescene: SKScene, ObservableObject, ...
1
vote
1
answer
115
views
Handling focus changes in tvOS SpriteKit app, where scene is embedded in a SwiftUI SpriteView
I'm having a mare trying to receive TV remote navigation (via the focus engine) in my SpriteKit game.
I've got a SwiftUI tvOS app with the following heirarchy:
struct SwatchGridSceneView: View {
...
1
vote
1
answer
123
views
Why is SKNode bound to MainActor?
In the following code:
public class Foo {
public func createNode() -> SCNNode {
return SCNNode()
}
public func createNode() -> SKNode {
return SKNode()
}
}
...
0
votes
1
answer
233
views
Apple Activity Sparkle ring effect with SwiftUI
I'm trying to recreate the sparkle effect from Apple's activity ring animation using SwiftUI. I've found Paul Hudson's Vortex library, which includes a sparkle effect, but as a beginner in SwiftUI ...
1
vote
0
answers
35
views
How to transition the overlay SKScene of a SCNView?
I have a SCNView showing an overlay SKView.
I want to transition to another overlay SKView.
let newScene = MyNewSKScene()
let reveal = SKTransition.reveal(with: .down, duration: 1)
currentSKScene....
0
votes
0
answers
72
views
Spritekit crashes sporadically on SKAction.move
I'm developing an app that moves a "grid" with Spritekit SKAction.move, based on frequent updates from ARKit. It crashes sporadically at camera?.run(moveToAction). Sometimes the app runs for ...
0
votes
2
answers
57
views
Recreating exactly the same ball, HTML5 to SpriteKit
I have the following SCSS code to define a ball I have in a game:
$color-green-dark: #226f54;
$color-cream: #f4f0bb;
$color-coffee: #7b4b39;
$color-brown: #43291f;
.ballType1 {
display: flex;
...
0
votes
1
answer
133
views
Label not showing on Tutorial SKScene
Good morning,
I am having an issue with my SKLabel not showing on my Tutorial SKScene. My code is below, I can't seem to find where I went wrong. When trying to add the SKLabel manually, it works fine....
0
votes
0
answers
91
views
How to create a mini-map of a SpriteKit scene using a different camera position
I have a SpriteKit SKScene presented via SwiftUI SpriteView.
What I want is a mini-map that is a real-time duplicate of the SKScene.
So, whatever happens in the main scene also happens in the mini-map....
1
vote
0
answers
126
views
How to detect the location of a mouseDown event for a iOS App using Swift?
How to detect the location of a mouseDown event for a iOS App using Swift?
With the following code snippet, I get the error "Value of type 'UIEvent' has no member 'location' in scope"?
...
0
votes
0
answers
119
views
How to detect touch inputs in SKScene on watchOS SpriteKit?
I'm trying to display a SKScene inside SwiftUI on watchOS and detect touch events.
var body: some View {
GeometryReader { reader in
SpriteView(scene: GameScene(size: reader....
0
votes
1
answer
86
views
Changing a texture on a custom spritenode class drops the framerate, but only the first time?
I'm working on a game right now, in which when triggered, my custom spritenode subclass, FireAlarm, performs a function where it changes it's texture twice and spawns an "explosion" node. ...
0
votes
0
answers
74
views
Swift Playground does not find SpriteKit particle file
I'm making a a project that has to use swift playground (.swiftpm);
It uses swiftUI for some elements but the main is on a SpriteKit Scene. My problem is that I want to use a particle and it just can'...