655 questions
0
votes
0
answers
52
views
How to hit-detect sprites but pass through background clicks in a transparent window?
I have an app built [in Objective C] for MacOS using SKScene and GameScene that has a floating window with some text in it (a clock). It works great, floats and shows the text. I have implemented hit ...
1
vote
1
answer
72
views
Weird Color-behaviour in SKScene for UIColor from Color
I have a SKScene, which runs an action, which is spawing notes. The scene runs in a SwiftUI View.
The Notes color originates from a Color (from Assets) which is having a Dark and Any mode variant.
...
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 ...
1
vote
1
answer
244
views
How to transitions between scenes using SpriteView in SwiftUI?
I have two scenes I want to transition between:
class TestGameScene: SKScene {
override func didMove(to view: SKView) {
size = view.frame.size
scaleMode = .resizeFill
let ...
1
vote
0
answers
54
views
How to determine size of SCNPlane to cover entire SKScene
I am developing an iOS application for a "green screen" using ARKit. That is display an image as a background in a ARFaceTrackingConfiguration AR session (similar to the "green screen&...
0
votes
0
answers
46
views
AdMob Banner Ad won't display in Swift SpriteKit game
I am creating a game in GameScene/SKScene using SpriteKit, and I am trying to display a AdMob Banner Ad. Somehow the Banner Ad won't show up.
This is the Banner Ad part of my code that I am currently ...
2
votes
1
answer
281
views
SKScene's update function appears to not work
I'm a mega-noob to SpriteKit / iOS dev, so sorry if this is a stupid question.
What I'm trying to do is have a small game presented in a SwiftUI View. Everything works mostly perfect, except that for ...
0
votes
1
answer
48
views
Neither adding a SKShapeNode nor adding a SKLabelNode to a SKScene appears to work?
Neither adding a SKShapeNode nor adding a SKLabelNode to a SKScene appears to work?
My gut guesses that I have a coordinate problem .. so here's the short code snippet which I have placed in my ...
0
votes
0
answers
53
views
Adding a Mac trackpad scroll gesture to a SKScene
To scroll a SKNode (called scroller) within a SKScene (called menuScene), I'm doing the following, which works perfectly but I'm not sure if it's the correct way to achieve this.
Within the ...
0
votes
1
answer
84
views
How do I eliminate SKScene.scaleMode = .aspectFit cutting off on all 4 sides with rotation?
How do I eliminate SKScene.scaleMode = .aspectFit cutting off on all four sides with rotation?
I read elsewhere:
.aspectFit Scales the content to fill the size of the view.
Some portion of the ...
0
votes
1
answer
83
views
My SKScene will show sized correctly in the Simulator, before rotation, but not after?
My SKScene will show sized correctly in the Simulator, before rotation, but not after?
If the Simulator is preset to Portrait, my SKScene is sized correctly .. and ditto if preset to Landscape.
But, ...
2
votes
0
answers
486
views
How to create a 'snow that's pile up' effect in SwiftUI
There are a lot of tutorials out there about how to create a rainfall and snowfall effect using SKScene.
I was wondering if anyone has any idea how I could create the effect of snow accumulating at ...
1
vote
0
answers
38
views
SpriteKit simulation step stutter
I am making a very simple game in SpriteKit where a sprite is going in a straight line from left to right.
I use applyForce() to give it a constant push. I noticed though, that there are random ...
1
vote
1
answer
207
views
How to detect two simultaneous touches in xcode spritekit?
I am trying to detect two simultaneous touches in my sprite kit game, but the game only detects my first touch and ignores the second one.
I am using touchesBegan, touchesMoved, and touchesCancelled:
...
1
vote
1
answer
388
views
Listening for click/touch events in SKScene on MacOS in a SwiftUI SpriteView
I'm trying to intercept mouse click events inside SpriteKit SKScene inside a a SwiftUI SpriteView in Mac OS. Overriding touchesBegun() that accepts an NSEvent object is never called when I click ...
0
votes
1
answer
230
views
How to pass in parameters to SKScene Class and then present the scene, within SpriteKit
I have a class 'GameplaySceneClass' which is an SKScene and I would like to pass parameters to it and then present the scene. The class can be seen below
class GameplaySceneClass: SKScene, ...
1
vote
1
answer
1k
views
How do you handle onChange() of @EnvironmentObject in an SKScene, and not break the scene rendering?
In the test code below the blue ellipse is drawn, but the red ellipse is not drawn. Is there a way to handle the onChange and call a drawing function in a SpriteKit scene? (The print statement inside ...
1
vote
0
answers
99
views
Change Letterbox Color
I have a SKScene which I am Using aspectFit scaleMode because I want use this scene across multiple devices. Is there any way to change the letterbox color to transparent?
This is the result of my ...
0
votes
1
answer
195
views
Properly Converting a point in `SKScene` to a location for a `UIView`
I have a UIView that I want to position on top of a certain area in an SKScene.
This is the point that I have in my SKScene:
guard let point = elementCGPoints.centroid() else {
return
}
...
2
votes
3
answers
1k
views
GCVirtualController not displaying with SKScene
The Virtual controllers appear but are then obscured by objects added to the view. I've also tried adding the virtual controllers in the UIViewController but this doesn't work either.
Is it possible ...
3
votes
1
answer
239
views
SKView.presentScene with transition not working if have shown another SKView
Update - see my own answer, it was a retain cycle with very indirect results. I wrote an article about it and the struggle to diagnose.
I have a very weird bug apparently as some kind of side-effect ...
1
vote
1
answer
209
views
SpriteKit SKScene not resizing correctly to fit iPhone 12
I've created a new SpriteKit project and want the scene to fill the screen entirely. I have defined the GameScene with iPhone 12 screen dimensions (390pt x 844pt) and specified the following in ...
0
votes
1
answer
76
views
Call a function from a different swift file
XCode Version 12.4 (12D4e)
The first SKScene class in Functions.swift included the buildBackground function which I want to call in different SKScene class.
class Functions: SKScene {
func ...
2
votes
1
answer
342
views
SKScene Viewable Size smaller than View bounds
I know my question is similar to SKScene view not filling screen but the answer there does not answer the issue I am having.
I want the screen to fill the entire screen and not just a sub-section of ...
1
vote
1
answer
1k
views
SwiftUI: Preload View without displaying
I'd like to "preload" a view (including a SKScene) to gather the bounds of the display area of this scene.
The size information is needed to precompute additional data, the computation ...
0
votes
1
answer
47
views
How to call a GameViewController function form SKScene which is overlaid
I have: GameViewController, where I setup a 3D scene and a function "fire". Then I have another SKScene, which is overlaid, so I cannot click the nodes on the 3D scene. On the SKScene I have ...
1
vote
1
answer
227
views
How to display AdMob Banner Ad on SKScene in SpriteKit?
I want to display an AdMob Banner Ad over an SKScene. Right now, I have the following code in the GameViewController, but nothing is appearing in the SKScene. Do I need to include code in the didMove ...
0
votes
1
answer
27
views
How to propagate the action from SKScene component to UIViewController
in XCode 12, using Swift 5, create a new Project using the Game SpriteKit technology. That generates amongst other things:
GameViewController.swift
GameScene.swift
In GameScene.swift I added
after ...
1
vote
0
answers
84
views
How to make part of a view controller SKScene and use both on the same screen?
I try to make a view controller, where i.e top half of the screen is SKScene, and bottom half of the screen is normal scene, I mean with buttons etc. Is this possible? I created a Single View ...
1
vote
0
answers
168
views
How to keep ObservedObject SKScene up to date with SpriteKit's presented Scene?
Right now I am setting up SwiftUI to use as my UI in SpriteKit game. I have it set up so my game launches and works fine. My UI view is set up like this
struct GameView: View{
@ObservedObject var ...
2
votes
1
answer
301
views
SpriteKit - SKScene bounds are not equal to SKView bounds
Recently I've created a new Xcode - Game project. Without touching anything I ran the template. I was expecting a standard Hello World! app, but I noticed one thing. Instead of pretty filled ...
0
votes
1
answer
109
views
SpriteKit - SKShapeNode from a loaded SKScene not rendered
I'm loading a SKScene from a file. In it, a SKShapeNode that I can see on the screen. But if set the "custom class" to a class like TestNode below, the ShapeNode won't be rendered: ...
1
vote
1
answer
313
views
SceneKit: z value of tap location?
I am using sceneKit in my project, and would like to add a red sphere (as a marker)on the location that the user taps on a 3d model of a human body (see picture below). With the code I have currently, ...
2
votes
1
answer
255
views
ios14 Xcode 12 - Sprites do not show when touching SwiftUI objects but work when touching SKScene
I am working on a simple game to learn the new functionality of SwiftUI with SpriteKit in Xcode 12. When a user touches the SKScene touchesBegan() everything works as expected. When a user touches the ...
0
votes
1
answer
84
views
How to handle sideways swipes
I am creating a game, where you control using swipes and I wanted to know if it is possible to handle sideways swipes using UIGestureRecodnizer?
If so how do I do it.
In other word:
Instead of having ...
0
votes
0
answers
19
views
Use multiple classes to control a single SKScene [duplicate]
I'm currently making a game with several levels in Swift. Each level is controlled by its own class that is initialised when the level is to be played. Is it possible to connect all these classes to a ...
0
votes
1
answer
134
views
Custom SKScene is not displaying in AR
I have created SKScene via SpriteKit tested it like 2D app. Here is my viewController. Everything works fine.
class GameViewController: UIViewController {
override func viewDidLoad() {
...
1
vote
1
answer
115
views
Is it possible to handle calculations after didApplyConstraints inside of a Delegating class?
I made a subclass of SKSpriteNode called JoyStick that follows the delegate pattern, where its delegate is GameScene. In an effort to further clean up the GameScene, the JoyStick class also implements ...
1
vote
2
answers
683
views
How to properly encapsulate touch event handling in a SKSpriteNode and pass data back to a SKScene
I'm writing a game in SpriteKit that has a joystick to control the player. Previously, I had kept most of the joystick logic in the main GameScene's touchesBegan, touchesMoved, and touchesEnded ...
2
votes
1
answer
218
views
Allow touch propagation in SpriteKit
Given a SpriteKit scene s, and one node a of type T that inherits from SKSpriteNode contained within s, if both s and a override any touch handler, the touch event is called exclusively on what seems ...
1
vote
0
answers
81
views
SKScene Won't Present When SubView Is Added To View Controller
I tried to add a subview to my GameViewController (because I want to add a banner ad at the bottom). I created it as follows:
if let view = self.view as! SKView? {
let subView = SKView(...
0
votes
0
answers
496
views
Export a sprite kit scene as an image at full size
I have a program that used sktilemap and noise map to generate maps. At the end i have a code to export the scene as an image, but the image is cropped and i see less content in the saved image than ...
0
votes
3
answers
951
views
How To Present a SKScene from a UIViewController
I am creating this game in SpriteKit.
At first launch, the GameViewController presents another ViewController called the MenuViewController linked with a storyboard.
And in the MenuViewController ...
2
votes
2
answers
328
views
SpriteKit avoid collision between two nodes
Desired behaviour
The red node (players arm) is connected to the blue one with a pinned joint.
The red node has a physicsBody because: 1) it should move if the blue node does and 2) it should collide ...
0
votes
2
answers
196
views
How to access text element from a .dae file in SceneKit?
I have a .dae file which is in shape of a Medal. Now this .dae file has a label element. I want to load this .dae file and want to update text on that label at runtime so user name will come there.
...
0
votes
1
answer
45
views
is there a way to auto adjust sk scenes to fit all iPhone horizontal screen ratios
I am creating an iOS game using sprite kit scene. My sprite kit scenes are sit to a scale value of x = 1136 by y = 640, creating a horizontal game play. This resolution adjusts to all iPhones up to ...
0
votes
1
answer
52
views
How to Create multiple SKShapeNode in a correct order?
multiple SKShapeNode are created like below:
for i in 1...20 {
let waitAct = SKAction.wait(forDuration: delay)
self.run(waitAct) {
let disc = SKShapeNode(rectOf: ...
1
vote
0
answers
77
views
Time-control animations in a SpriteKit SKScene
Using CALayer's beginTime we're able to scrub through animations.
Is there any way to achieve the same when using SpriteKit?
Is there anything similar for SKScene or SKView?
1
vote
3
answers
529
views
SpriteKit Scene referenced with SKReferenceNode does not load custom class
I have a GameScene.sks a custom class GameScene.swift which is connected via the Custom Class Inspector (on the right in Xcode). This is working fine.
Now in the GameScene.swift where I want to ...
1
vote
0
answers
105
views
How can I restart or close then turn on an SKScene?
I am not looking to remove all children in the SkScene, I want to completely close the scene once the game is over.
Yes I have tried all of the solutions posted here, need some way of either ...