SpriteKit

RSS for tag

Drawing shapes, particles, text, images, and video in two dimensions using SpriteKit.

SpriteKit Documentation

Posts under SpriteKit subtopic

Post

Replies

Boosts

Views

Activity

[plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x60000276b020> F8BB1C28-BAE8-11D6-9C31-00039315CD46
Can anyone help me with the following output which is related to playing sounds/music in a SpriteKit game I'm working on? [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x60000276b020> F8BB1C28-BAE8-11D6-9C31-00039315CD46 I'm new to SpriteKit and I've searched the web for answers and found quite a few post concerning the warning (I wouldn't call it an error because the game and sound/music output works perfectly), but no definitive answers on fixing it. I get the warning regardless of how I play the music, adding SKAudioNode to the scene, creating an AVAudioPlayer, etcetera. I suppose I could just ignore the warning as it doesn't seem to impact my game, but I just hate not understanding warnings in the Xcode output window. I'm also getting the below in the output window which I believe is related. AudioObjectGetPropertyData: no object with given ID 0 throwing -10878
0
0
1.7k
Sep ’22
I tagged some Sprite Atlas to On Demand Resources' Tags and not loading in TestFlight
My game's new version used On Demand Resources with Sprite Atlas. Everything work fine in Simulator until I submitted a version to AppStoreConnect and install through TestFlight. All Sprite Atlas' assets only show "X" inside my game. Is it TestFlight's bug? Can I still submit for Review and will it working fine in App Store version?
1
0
1.8k
Sep ’22
Future of Spritekit?
Hi,I coming from another engine, which is Cocos Creator, and would like to know, if SpriteKit is worth learning along with Swift. I've already started working on a Game using Xcode 9.2, and Swift, and looking at some tutorials along the way. But, I'm really somewhat worried about the direction if any SpriteKit will take. I've some posts in the community, concerning the lack of support from Apple towards this framework, instability, etc........So, my main question to Apple moderators, is, does SpriteKit have a future in the Apple Ecosystem, or should I just stick with another engine. One of the main reasons for me to switching from my other engine, is that, I really like ARKit, and the potential it has to be the next frontier in game making, but I wouldn't like to waste my time in a framework that could be not supported in the near future.....Would really appreciate any thoughts and info regarding this.......Thanks for the time and God Bless....Sincerely,Sunday
7
1
7.6k
Aug ’22
SpriteKit Game
OK I'm trying to make a sprite(model.Emmiter) that shoots balls(EnergyBalls) and the balls wont emit at the touch location: import SpriteKit import GameplayKit class Sprites {     var Emmiter: SKSpriteNode = .init(imageNamed: "Emmiter") } class GameScene: SKScene {     var model: Sprites = .init()     var Emmiter = Sprites().Emmiter     var playableRect: CGRect = .zer     var lastTouch: CGPoint = .zero     override func didMove(to view: SKView) {        Emmiter.position = CGPoint(x: size.width / 2, y: size.width/* view.frame.minY + 100 */)         print(Emmiter.position)         self.addChild(Emmiter)     }               func touchDown(atPoint pos : CGPoint) {         lastTouch = pos         let rotation = -atan2(             lastTouch.x - Emmiter.position.x,             lastTouch.y - Emmiter.position.y         )         Emmiter.run(             .rotate(                 toAngle: rotation,                 duration: 0.25             )         )         fireEnergyBall(atPoint: lastTouch)     }          func touchMoved(toPoint pos : CGPoint) {     }          func touchUp(atPoint pos : CGPoint) {     }          func fireEnergyBall(atPoint location: CGPoint) {         let EnergyBall = SKSpriteNode(imageNamed: "Energy")         EnergyBall.position = Emmiter.position         print(EnergyBall.position)                  let fly: SKAction = .run {             EnergyBall.run(.move(to: location, duration: 1))             DispatchQueue.main.asyncAfter(deadline: .now() + 1) {                     EnergyBall.un(.sequence([.scale(to: 0, duration: 0.125), .removeFromParent()]))                 }         }         EnergyBall.run(fly)         self.addChild(EnergyBall)     }     override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {         let rotation = -atan2(             touches.first!.location(                 in: self             ).x - Emmiter.position.x,             touches.first!.location(                 in: self             ).y - Emmiter.position.y         )         Emmiter.run(             .rotate(                 toAngle: rotation,                 duration: 0.25             )         )         fireEnergyBall(atPoint: touches.first!.location(in: self.view))     }          override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {     }          override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {     }          override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {     }               override func update(_ currentTime: TimeInterval) {              } }
2
0
1k
Aug ’22
Speech Recognition 'recognitionTask' Function Not Executing
I'm building a game where the player is able to speak commands, so I want to enable speech-to-text capability. I've setup the required info.plist property (for speech recognition privacy) as well as the App Sandbox hardware setting (for audio input). I've confirmed that the application is listening via the audio tap and sending audio buffers to the recognition request. However, the recognition task never executes. NOTE: This is for MacOS, NOT iOS. Also, it works when I have this in a Playground, but when I try to do this in an actual application, the recognition task isn't called. Specs: MacOS: 12.1 XCode: 13.2.1 (13C100) Swift: 5.5.2 Here is the code that I've placed in the AppDelegate of a freshly built SpriteKit application: // // AppDelegate.swift // import Cocoa import AVFoundation import Speech @main class AppDelegate: NSObject, NSApplicationDelegate {   private let speechRecognizer = SFSpeechRecognizer(locale: Locale(identifier: "en-US"))!   private let audioEngine = AVAudioEngine()   private var recognitionRequest: SFSpeechAudioBufferRecognitionRequest?   private var recognitionTask: SFSpeechRecognitionTask?   func applicationDidFinishLaunching(_ aNotification: Notification) {     SFSpeechRecognizer.requestAuthorization(requestMicrophoneAccess)   }   func applicationWillTerminate(_ aNotification: Notification) {     // Insert code here to tear down your application   }   func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {     return true   }   fileprivate func requestMicrophoneAccess(authStatus: SFSpeechRecognizerAuthorizationStatus) {     OperationQueue.main.addOperation {       switch authStatus {       case .authorized:           self.speechRecognizer.supportsOnDeviceRecognition = true           if let speechRecognizer = SFSpeechRecognizer() {             if speechRecognizer.isAvailable {               do {                 try self.startListening()               } catch {                 print(">>> ERROR >>> Listening Error: \(error)")               }             }           }       case .denied:           print("Denied")                 case .restricted:           print("Restricted")                 case .notDetermined:           print("Undetermined")                 default:           print("Unknown")       }     }   }   func startListening() throws {     // Cancel the previous task if it's running.     recognitionTask?.cancel()     recognitionTask = nil           let inputNode = audioEngine.inputNode     // Configure the microphone input.     let recordingFormat = inputNode.outputFormat(forBus: 0)     inputNode.installTap(onBus: 0, bufferSize: 1024, format: recordingFormat) {(buffer: AVAudioPCMBuffer, when: AVAudioTime) in /********** * Confirmed that the following line is executing continuously **********/       self.recognitionRequest?.append(buffer)     }     startRecognizing()     audioEngine.prepare()     try audioEngine.start()   }   func startRecognizing() {     // Create a recognition task for the speech recognition session.     recognitionRequest = SFSpeechAudioBufferRecognitionRequest()     guard let recognitionRequestInternal = recognitionRequest else { fatalError("Unable to create a SFSpeechAudioBufferRecognitionRequest object") }     recognitionRequestInternal.shouldReportPartialResults = true     recognitionRequestInternal.requiresOnDeviceRecognition = true /************** * Confirmed that the following line is executed, * however the function given to 'recognitionTask' is never called **************/     recognitionTask = speechRecognizer.recognitionTask(with: recognitionRequestInternal) { result, error in       var isFinal = false               if result != nil {         let firstTranscriptionTimestamp = result!.transcriptions.first?.segments.first?.timestamp ?? TimeInterval.zero         isFinal = result!.isFinal || (firstTranscriptionTimestamp != 0)       }               if error != nil {         // Stop recognizing speech if there is a problem.         print("\n>>> ERROR >>> Recognition Error: \(error)")         self.audioEngine.stop()         self.audioEngine.inputNode.removeTap(onBus: 0)         self.recognitionRequest = nil         self.recognitionTask = nil       } else if isFinal {         self.recognitionTask = nil       }     }   } }
2
0
1.6k
Aug ’22
Adding gradient background to SKScene
Hi.I am trying to add background with gradient color to my SKScene:class GameScene: SKScene { override func didMove(to view: SKView) { let gradientView = UIView(frame: CGRect(x: 0, y: 0, width: frame.size.width, height: frame.size.height)) let image = UIImage.gradientBackgroundImage(bounds: CGRect(x: 0, y: 0, width: frame.width, height: frame.height), colors: [UIColor.yellow.cgColor, UIColor.blue.cgColor]) let background = SKSpriteNode(color: UIColor(patternImage: image), size: frame.size) addChild(background) } } extension UIImage { /** http://www.riptutorial.com/ios/example/14328/gradient-image-with-colors */ static func gradientBackgroundImage(bounds: CGRect, colors: [CGColor]) -&gt; UIImage { let gradientLayer = CAGradientLayer() gradientLayer.frame = bounds gradientLayer.colors = colors UIGraphicsBeginImageContext(gradientLayer.bounds.size) gradientLayer.render(in: UIGraphicsGetCurrentContext()!) let image = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() return image! } }This is not working. Is there a better way to add gradient background to the SKScene?Thanks a lot!EDIT:If I do this in didMove(to view:):self.view?.backgroundColor = UIColor.blue let backgroundDep = IGABackgroundLayer().gradientMetar() // My method to create CAGradientLayer backgroundDep.frame = self.view!.bounds self.view!.layer.insertSublayer(backgroundDep, at: 0)...background is created nicely but added SKNodes are not seen on top of it.
5
0
4.6k
Jul ’22
SpriteKit objects not colliding
I am new to SpriteKit, and I am trying to make a simple game. however, when trying to integrate gravity, the player foes not hit the floor, but instead falls behind (despite having the same zPosition). I would like to know what I need to have the floor and player collide. I have currently set the collisionBitMask and categoryBitMask, have them on the same zPosition, and have gravity turned off of the floor, but enabled on the player. is there anything else that needs to be done?
0
0
622
Jun ’22
How to turn AR SpriteKit App into AR SceneKit App
Hello! I am new to ARKit and currently working on this sample SpriteKit AR application from Apple. To use ARKits debug option of visualizing the feature points I am trying to change the app from an AR SpriteKit base to an AR SceneKit base. (I thought it should be possible after watching this Apple session.) Therefore I made some changes. But unfortunately, the application doesn't show the camera input anymore and throws an exception after some time. The object detector still correctly identifies objects but the main screen stays gray. Help would be much appreciated! Best regards! Main changes: @IBOutlet weak var sceneView: ARSCNView! // @IBOutlet weak var sceneView: ARSKView! class ViewController: ARSCNViewDelegate {} // class ViewController: ARSKViewDelegate {} Put the SpriteKit overlayScene into a SCNPlane. Had to change how child nodes get hidden when relocalization happens.
1
1
818
Jun ’22
Using the Rec. 2020 color gamut in SpriteKit
About a month ago I asked whether I could use HDR in SpriteKit. This wasn't a well-phrased question since HDR seems to mean different things in different questions, which probably led to my question going unanswered. What I meant to ask was whether it's possible to use assets that have a color gamut that many modern devices are capable of displaying (XDR is somewhat standard among mid- to high-end devices). In other words: Is SpriteKit keeping up with the hardware? If not, what framework options do I have that can quickly display large Rec. 2020 images? Do any of the Core frameworks offer this capability?
1
0
1.3k
May ’22
SKPhysicsContactDelegate not works
I wanna add a score when the character contacts with the 'coins' and game over when it contacts with the 'enemies'. But it doesn't work. I compiled the ...Category and &lt;SKPhysicsContactDelegate&gt; code in GameScene.h and these:- (instancetype)initWithSize:(CGSize)size { if (self = [super initWithSize:size]) { self.character = [SKSpriteNode spriteNodeWithImageNamed:@"character"]; self.character.position = CGPointMake(100, 100); [self addChild:self.character]; self.physicsWorld.gravity = CGVectorMake(0,0); self.physicsWorld.contactDelegate = self; } return self; }in .m above didMoveToView method. Can I use initWithSize in Xcode 8? And I do use these code in .m:character.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:character.size]; //1 character.physicsBody.dynamic = YES; //2 character.physicsBody.categoryBitMask = characterCategory; //3 character.physicsBody.contactTestBitMask = coinCategory | enemiesCategory;//4 character.physicsBody.collisionBitMask = 0; // 5I use them in "setPhysicsBody:(SKPhysicsBody *)physicsBody" method. And of couse I compiled the didBeginContact method. Did I miss anything? Please help me. Thank you very much.
10
0
2.7k
May ’22
animating all nodes
I'm trying to develop a system with skspritenode spawn and then they follow the player but when ever skspritenode spawn the original action stops so it ends up with only one following the node instead of all of them.
0
0
612
May ’22
SpriteKit game + inAppPurchases
Hi, I've written a SpriteKit game but am finding it hard to know how to add inappropriate purchases functionality within this, I know you can add a spritekit game above a swiftUI but unsure if can add swiftUI to spritekit game so can add purchase code, all info from within SpriteKit seems to not function. Or even better as code I know and love, can you add purchase functionality from within SpriteKit. would love to hear from you, Ruth
0
0
639
May ’22
SKView showsFields draws only on a portion of the screen
The SKView.showsFields = true only draws on a portion of the screen - nothing shows on the bottom-left. This can be easily tested using Apple's default game playground. I only removed the action for the Hello World label and added a radialGravityField into the scene. Also other fields like electricField do not draw anything on the screen. Tested in Xcode 11.7 and Xcode 12.5.1. Is this a bug in the recent releases? override func didMove(to view: SKView) { // ... let field = SKFieldNode.radialGravityField() addChild(field) } and sceneView.showsFields = true
4
1
1.5k
Apr ’22
Ultra-large texture atlases in SpriteKit
I'm looking to use high-quality and large images as animated sprites via SpriteKit. Right now the default maximum size of a texture atlas is 4096*4096, which is at least an order of magnitude below what I need. There's an option to create custom maximum sizes, but the tiny default and the age of the SpriteKit framework is giving me second thoughts even though I'd very much like to stick with an Apple framework and not have to rely on another party like Unity. Before I invest my time and energy into SpriteKit I'd like to know whether the decade-old framework, running on modern hardware (A11 and newer), can support massive texture atlases while maintaining decent performance (~30 FPS). If not, is it possible to implement something similar in less antiquated frameworks, such as RealityKit (non-AR). Thanks in advance for your time.
0
0
930
Apr ’22
How to display sprites in RealityKit?
My project involves no camera passthrough and relies heavily on sprites, but I've been discouraged from using the aging (and possibly dying) SpriteKit or SceneKit as my rendering engine by Apple engineers (here) so I'm exploring other options. Is it possible to display 2D sprites fluidly using this framework in a non-AR context? Is it possible to create, say, a 2D platformer using just RealityKit?
1
0
1.4k
Apr ’22
SKScene jitters/lags when a new SKSpriteNode is added
I'm constructing a Swift Playground with UIKit that contains an SKScene. After creating the code I'm planning to use within an Xcode project, I tried to adapt it into my Playground. I encountered an issue while running the Playground - when a new SKSpriteNode is added to the Scene, the new and existing nodes jitter, freeze, and lag for a split-second, the FPS counter drops to around 49fps, then returns to smooth 60fps. No errors or warnings are spat, and the console is completely empty. The scene in the project didn't have this issue, and I can't recreate it on another project - even when I directly copy-paste the code from the Playground to the project. I've seen other posts with this question - and made a few myself elsewhere - and there's been no responses. I desperately need help for this as nothing I've tried is working and the deadline is in a few days! Thanks! The code that is in effect for this SKScene is below. class SimulatorController: UIViewController { override func loadView() { let view = SKView() let scene = GameScene(size: view.bounds.size) view.showsFPS = true view.showsNodeCount = true view.ignoresSiblingOrder = true scene.scaleMode = .resizeFill view.presentScene(scene) self.view = view } } class GameScene: SKScene { override func didMove(to view: SKView) { run(SKAction.repeatForever(SKAction.sequence([ SKAction.run(addNeutron), SKAction.wait(forDuration: 1) ]) )) } func random() -> CGFloat { return CGFloat(Float(arc4random()) / 0xFFFFFFFF) } func random(min: CGFloat, max: CGFloat) -> CGFloat { return random() * (max - min) + min } func addNeutron() { let neutron = SKSpriteNode(imageNamed: "neutron.heic") neutron.size = CGSize(width: 20, height: 20) neutron.physicsBody = SKPhysicsBody(rectangleOf: neutron.size) neutron.physicsBody?.isDynamic = true let actualX = random(min: 0, max: size.width) let actualY = random(min: 0, max: size.height) neutron.position = CGPoint(x: actualX, y: actualY) addChild(neutron) let actualDuration = random(min: CGFloat(2.0), max: CGFloat(4.0)) let actualX2 = random(min: 0, max: size.width) let actualY2 = random(min: 0, max: size.height) let actionMove = SKAction.move(to: CGPoint(x: actualX2, y: actualY2), duration: TimeInterval(actualDuration)) let actionMoveDone = SKAction.removeFromParent() neutron.run(SKAction.sequence([actionMove, actionMoveDone])) } }
2
0
1.5k
Apr ’22
SKAudioNode in iOS9 and volume
I'm trying to use the new SKAudioNode in iOS9. I get the sound to play, but can't seemt to access the nodes volume?
Replies
4
Boosts
0
Views
3.6k
Activity
Sep ’22
[plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x60000276b020> F8BB1C28-BAE8-11D6-9C31-00039315CD46
Can anyone help me with the following output which is related to playing sounds/music in a SpriteKit game I'm working on? [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x60000276b020> F8BB1C28-BAE8-11D6-9C31-00039315CD46 I'm new to SpriteKit and I've searched the web for answers and found quite a few post concerning the warning (I wouldn't call it an error because the game and sound/music output works perfectly), but no definitive answers on fixing it. I get the warning regardless of how I play the music, adding SKAudioNode to the scene, creating an AVAudioPlayer, etcetera. I suppose I could just ignore the warning as it doesn't seem to impact my game, but I just hate not understanding warnings in the Xcode output window. I'm also getting the below in the output window which I believe is related. AudioObjectGetPropertyData: no object with given ID 0 throwing -10878
Replies
0
Boosts
0
Views
1.7k
Activity
Sep ’22
I tagged some Sprite Atlas to On Demand Resources' Tags and not loading in TestFlight
My game's new version used On Demand Resources with Sprite Atlas. Everything work fine in Simulator until I submitted a version to AppStoreConnect and install through TestFlight. All Sprite Atlas' assets only show "X" inside my game. Is it TestFlight's bug? Can I still submit for Review and will it working fine in App Store version?
Replies
1
Boosts
0
Views
1.8k
Activity
Sep ’22
Future of Spritekit?
Hi,I coming from another engine, which is Cocos Creator, and would like to know, if SpriteKit is worth learning along with Swift. I've already started working on a Game using Xcode 9.2, and Swift, and looking at some tutorials along the way. But, I'm really somewhat worried about the direction if any SpriteKit will take. I've some posts in the community, concerning the lack of support from Apple towards this framework, instability, etc........So, my main question to Apple moderators, is, does SpriteKit have a future in the Apple Ecosystem, or should I just stick with another engine. One of the main reasons for me to switching from my other engine, is that, I really like ARKit, and the potential it has to be the next frontier in game making, but I wouldn't like to waste my time in a framework that could be not supported in the near future.....Would really appreciate any thoughts and info regarding this.......Thanks for the time and God Bless....Sincerely,Sunday
Replies
7
Boosts
1
Views
7.6k
Activity
Aug ’22
SpriteKit Game
OK I'm trying to make a sprite(model.Emmiter) that shoots balls(EnergyBalls) and the balls wont emit at the touch location: import SpriteKit import GameplayKit class Sprites {     var Emmiter: SKSpriteNode = .init(imageNamed: "Emmiter") } class GameScene: SKScene {     var model: Sprites = .init()     var Emmiter = Sprites().Emmiter     var playableRect: CGRect = .zer     var lastTouch: CGPoint = .zero     override func didMove(to view: SKView) {        Emmiter.position = CGPoint(x: size.width / 2, y: size.width/* view.frame.minY + 100 */)         print(Emmiter.position)         self.addChild(Emmiter)     }               func touchDown(atPoint pos : CGPoint) {         lastTouch = pos         let rotation = -atan2(             lastTouch.x - Emmiter.position.x,             lastTouch.y - Emmiter.position.y         )         Emmiter.run(             .rotate(                 toAngle: rotation,                 duration: 0.25             )         )         fireEnergyBall(atPoint: lastTouch)     }          func touchMoved(toPoint pos : CGPoint) {     }          func touchUp(atPoint pos : CGPoint) {     }          func fireEnergyBall(atPoint location: CGPoint) {         let EnergyBall = SKSpriteNode(imageNamed: "Energy")         EnergyBall.position = Emmiter.position         print(EnergyBall.position)                  let fly: SKAction = .run {             EnergyBall.run(.move(to: location, duration: 1))             DispatchQueue.main.asyncAfter(deadline: .now() + 1) {                     EnergyBall.un(.sequence([.scale(to: 0, duration: 0.125), .removeFromParent()]))                 }         }         EnergyBall.run(fly)         self.addChild(EnergyBall)     }     override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {         let rotation = -atan2(             touches.first!.location(                 in: self             ).x - Emmiter.position.x,             touches.first!.location(                 in: self             ).y - Emmiter.position.y         )         Emmiter.run(             .rotate(                 toAngle: rotation,                 duration: 0.25             )         )         fireEnergyBall(atPoint: touches.first!.location(in: self.view))     }          override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {     }          override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {     }          override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {     }               override func update(_ currentTime: TimeInterval) {              } }
Replies
2
Boosts
0
Views
1k
Activity
Aug ’22
Speech Recognition 'recognitionTask' Function Not Executing
I'm building a game where the player is able to speak commands, so I want to enable speech-to-text capability. I've setup the required info.plist property (for speech recognition privacy) as well as the App Sandbox hardware setting (for audio input). I've confirmed that the application is listening via the audio tap and sending audio buffers to the recognition request. However, the recognition task never executes. NOTE: This is for MacOS, NOT iOS. Also, it works when I have this in a Playground, but when I try to do this in an actual application, the recognition task isn't called. Specs: MacOS: 12.1 XCode: 13.2.1 (13C100) Swift: 5.5.2 Here is the code that I've placed in the AppDelegate of a freshly built SpriteKit application: // // AppDelegate.swift // import Cocoa import AVFoundation import Speech @main class AppDelegate: NSObject, NSApplicationDelegate {   private let speechRecognizer = SFSpeechRecognizer(locale: Locale(identifier: "en-US"))!   private let audioEngine = AVAudioEngine()   private var recognitionRequest: SFSpeechAudioBufferRecognitionRequest?   private var recognitionTask: SFSpeechRecognitionTask?   func applicationDidFinishLaunching(_ aNotification: Notification) {     SFSpeechRecognizer.requestAuthorization(requestMicrophoneAccess)   }   func applicationWillTerminate(_ aNotification: Notification) {     // Insert code here to tear down your application   }   func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {     return true   }   fileprivate func requestMicrophoneAccess(authStatus: SFSpeechRecognizerAuthorizationStatus) {     OperationQueue.main.addOperation {       switch authStatus {       case .authorized:           self.speechRecognizer.supportsOnDeviceRecognition = true           if let speechRecognizer = SFSpeechRecognizer() {             if speechRecognizer.isAvailable {               do {                 try self.startListening()               } catch {                 print(">>> ERROR >>> Listening Error: \(error)")               }             }           }       case .denied:           print("Denied")                 case .restricted:           print("Restricted")                 case .notDetermined:           print("Undetermined")                 default:           print("Unknown")       }     }   }   func startListening() throws {     // Cancel the previous task if it's running.     recognitionTask?.cancel()     recognitionTask = nil           let inputNode = audioEngine.inputNode     // Configure the microphone input.     let recordingFormat = inputNode.outputFormat(forBus: 0)     inputNode.installTap(onBus: 0, bufferSize: 1024, format: recordingFormat) {(buffer: AVAudioPCMBuffer, when: AVAudioTime) in /********** * Confirmed that the following line is executing continuously **********/       self.recognitionRequest?.append(buffer)     }     startRecognizing()     audioEngine.prepare()     try audioEngine.start()   }   func startRecognizing() {     // Create a recognition task for the speech recognition session.     recognitionRequest = SFSpeechAudioBufferRecognitionRequest()     guard let recognitionRequestInternal = recognitionRequest else { fatalError("Unable to create a SFSpeechAudioBufferRecognitionRequest object") }     recognitionRequestInternal.shouldReportPartialResults = true     recognitionRequestInternal.requiresOnDeviceRecognition = true /************** * Confirmed that the following line is executed, * however the function given to 'recognitionTask' is never called **************/     recognitionTask = speechRecognizer.recognitionTask(with: recognitionRequestInternal) { result, error in       var isFinal = false               if result != nil {         let firstTranscriptionTimestamp = result!.transcriptions.first?.segments.first?.timestamp ?? TimeInterval.zero         isFinal = result!.isFinal || (firstTranscriptionTimestamp != 0)       }               if error != nil {         // Stop recognizing speech if there is a problem.         print("\n>>> ERROR >>> Recognition Error: \(error)")         self.audioEngine.stop()         self.audioEngine.inputNode.removeTap(onBus: 0)         self.recognitionRequest = nil         self.recognitionTask = nil       } else if isFinal {         self.recognitionTask = nil       }     }   } }
Replies
2
Boosts
0
Views
1.6k
Activity
Aug ’22
'cyclone' is not a recognized processor for this target (ignoring processor)
Building and running a SpriteKit game on iPhone simulator starts up and after did move to view, I get this error and app abends with illegal instruction. Xcode beta 5, Big Sur beta 5 Apple Silicon Anyone else seen this?
Replies
12
Boosts
4
Views
6.8k
Activity
Aug ’22
Adding gradient background to SKScene
Hi.I am trying to add background with gradient color to my SKScene:class GameScene: SKScene { override func didMove(to view: SKView) { let gradientView = UIView(frame: CGRect(x: 0, y: 0, width: frame.size.width, height: frame.size.height)) let image = UIImage.gradientBackgroundImage(bounds: CGRect(x: 0, y: 0, width: frame.width, height: frame.height), colors: [UIColor.yellow.cgColor, UIColor.blue.cgColor]) let background = SKSpriteNode(color: UIColor(patternImage: image), size: frame.size) addChild(background) } } extension UIImage { /** http://www.riptutorial.com/ios/example/14328/gradient-image-with-colors */ static func gradientBackgroundImage(bounds: CGRect, colors: [CGColor]) -&gt; UIImage { let gradientLayer = CAGradientLayer() gradientLayer.frame = bounds gradientLayer.colors = colors UIGraphicsBeginImageContext(gradientLayer.bounds.size) gradientLayer.render(in: UIGraphicsGetCurrentContext()!) let image = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() return image! } }This is not working. Is there a better way to add gradient background to the SKScene?Thanks a lot!EDIT:If I do this in didMove(to view:):self.view?.backgroundColor = UIColor.blue let backgroundDep = IGABackgroundLayer().gradientMetar() // My method to create CAGradientLayer backgroundDep.frame = self.view!.bounds self.view!.layer.insertSublayer(backgroundDep, at: 0)...background is created nicely but added SKNodes are not seen on top of it.
Replies
5
Boosts
0
Views
4.6k
Activity
Jul ’22
SpriteKit objects not colliding
I am new to SpriteKit, and I am trying to make a simple game. however, when trying to integrate gravity, the player foes not hit the floor, but instead falls behind (despite having the same zPosition). I would like to know what I need to have the floor and player collide. I have currently set the collisionBitMask and categoryBitMask, have them on the same zPosition, and have gravity turned off of the floor, but enabled on the player. is there anything else that needs to be done?
Replies
0
Boosts
0
Views
622
Activity
Jun ’22
How to turn AR SpriteKit App into AR SceneKit App
Hello! I am new to ARKit and currently working on this sample SpriteKit AR application from Apple. To use ARKits debug option of visualizing the feature points I am trying to change the app from an AR SpriteKit base to an AR SceneKit base. (I thought it should be possible after watching this Apple session.) Therefore I made some changes. But unfortunately, the application doesn't show the camera input anymore and throws an exception after some time. The object detector still correctly identifies objects but the main screen stays gray. Help would be much appreciated! Best regards! Main changes: @IBOutlet weak var sceneView: ARSCNView! // @IBOutlet weak var sceneView: ARSKView! class ViewController: ARSCNViewDelegate {} // class ViewController: ARSKViewDelegate {} Put the SpriteKit overlayScene into a SCNPlane. Had to change how child nodes get hidden when relocalization happens.
Replies
1
Boosts
1
Views
818
Activity
Jun ’22
Using the Rec. 2020 color gamut in SpriteKit
About a month ago I asked whether I could use HDR in SpriteKit. This wasn't a well-phrased question since HDR seems to mean different things in different questions, which probably led to my question going unanswered. What I meant to ask was whether it's possible to use assets that have a color gamut that many modern devices are capable of displaying (XDR is somewhat standard among mid- to high-end devices). In other words: Is SpriteKit keeping up with the hardware? If not, what framework options do I have that can quickly display large Rec. 2020 images? Do any of the Core frameworks offer this capability?
Replies
1
Boosts
0
Views
1.3k
Activity
May ’22
SKPhysicsContactDelegate not works
I wanna add a score when the character contacts with the 'coins' and game over when it contacts with the 'enemies'. But it doesn't work. I compiled the ...Category and &lt;SKPhysicsContactDelegate&gt; code in GameScene.h and these:- (instancetype)initWithSize:(CGSize)size { if (self = [super initWithSize:size]) { self.character = [SKSpriteNode spriteNodeWithImageNamed:@"character"]; self.character.position = CGPointMake(100, 100); [self addChild:self.character]; self.physicsWorld.gravity = CGVectorMake(0,0); self.physicsWorld.contactDelegate = self; } return self; }in .m above didMoveToView method. Can I use initWithSize in Xcode 8? And I do use these code in .m:character.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:character.size]; //1 character.physicsBody.dynamic = YES; //2 character.physicsBody.categoryBitMask = characterCategory; //3 character.physicsBody.contactTestBitMask = coinCategory | enemiesCategory;//4 character.physicsBody.collisionBitMask = 0; // 5I use them in "setPhysicsBody:(SKPhysicsBody *)physicsBody" method. And of couse I compiled the didBeginContact method. Did I miss anything? Please help me. Thank you very much.
Replies
10
Boosts
0
Views
2.7k
Activity
May ’22
animating all nodes
I'm trying to develop a system with skspritenode spawn and then they follow the player but when ever skspritenode spawn the original action stops so it ends up with only one following the node instead of all of them.
Replies
0
Boosts
0
Views
612
Activity
May ’22
SKLabelNode blurry
Anyone know how to fix what seem to be an issue with SKLabelNode where it is very blurry? this started happening after i update xcode.
Replies
1
Boosts
0
Views
1.2k
Activity
May ’22
SpriteKit game + inAppPurchases
Hi, I've written a SpriteKit game but am finding it hard to know how to add inappropriate purchases functionality within this, I know you can add a spritekit game above a swiftUI but unsure if can add swiftUI to spritekit game so can add purchase code, all info from within SpriteKit seems to not function. Or even better as code I know and love, can you add purchase functionality from within SpriteKit. would love to hear from you, Ruth
Replies
0
Boosts
0
Views
639
Activity
May ’22
SKView showsFields draws only on a portion of the screen
The SKView.showsFields = true only draws on a portion of the screen - nothing shows on the bottom-left. This can be easily tested using Apple's default game playground. I only removed the action for the Hello World label and added a radialGravityField into the scene. Also other fields like electricField do not draw anything on the screen. Tested in Xcode 11.7 and Xcode 12.5.1. Is this a bug in the recent releases? override func didMove(to view: SKView) { // ... let field = SKFieldNode.radialGravityField() addChild(field) } and sceneView.showsFields = true
Replies
4
Boosts
1
Views
1.5k
Activity
Apr ’22
Ultra-large texture atlases in SpriteKit
I'm looking to use high-quality and large images as animated sprites via SpriteKit. Right now the default maximum size of a texture atlas is 4096*4096, which is at least an order of magnitude below what I need. There's an option to create custom maximum sizes, but the tiny default and the age of the SpriteKit framework is giving me second thoughts even though I'd very much like to stick with an Apple framework and not have to rely on another party like Unity. Before I invest my time and energy into SpriteKit I'd like to know whether the decade-old framework, running on modern hardware (A11 and newer), can support massive texture atlases while maintaining decent performance (~30 FPS). If not, is it possible to implement something similar in less antiquated frameworks, such as RealityKit (non-AR). Thanks in advance for your time.
Replies
0
Boosts
0
Views
930
Activity
Apr ’22
Displaying HDR content in SpriteKit
I'm looking to use high-quality and large images as animated sprites via SpriteKit. Is it possible to display sprites with HDR colors in SpriteKit? What about SpriteKit via SceneKit or RealityKit? I've looked all around and it seems as though *.PNG is the only accepted image format, and it doesn't seem to have HDR support.
Replies
0
Boosts
0
Views
1.4k
Activity
Apr ’22
How to display sprites in RealityKit?
My project involves no camera passthrough and relies heavily on sprites, but I've been discouraged from using the aging (and possibly dying) SpriteKit or SceneKit as my rendering engine by Apple engineers (here) so I'm exploring other options. Is it possible to display 2D sprites fluidly using this framework in a non-AR context? Is it possible to create, say, a 2D platformer using just RealityKit?
Replies
1
Boosts
0
Views
1.4k
Activity
Apr ’22
SKScene jitters/lags when a new SKSpriteNode is added
I'm constructing a Swift Playground with UIKit that contains an SKScene. After creating the code I'm planning to use within an Xcode project, I tried to adapt it into my Playground. I encountered an issue while running the Playground - when a new SKSpriteNode is added to the Scene, the new and existing nodes jitter, freeze, and lag for a split-second, the FPS counter drops to around 49fps, then returns to smooth 60fps. No errors or warnings are spat, and the console is completely empty. The scene in the project didn't have this issue, and I can't recreate it on another project - even when I directly copy-paste the code from the Playground to the project. I've seen other posts with this question - and made a few myself elsewhere - and there's been no responses. I desperately need help for this as nothing I've tried is working and the deadline is in a few days! Thanks! The code that is in effect for this SKScene is below. class SimulatorController: UIViewController { override func loadView() { let view = SKView() let scene = GameScene(size: view.bounds.size) view.showsFPS = true view.showsNodeCount = true view.ignoresSiblingOrder = true scene.scaleMode = .resizeFill view.presentScene(scene) self.view = view } } class GameScene: SKScene { override func didMove(to view: SKView) { run(SKAction.repeatForever(SKAction.sequence([ SKAction.run(addNeutron), SKAction.wait(forDuration: 1) ]) )) } func random() -> CGFloat { return CGFloat(Float(arc4random()) / 0xFFFFFFFF) } func random(min: CGFloat, max: CGFloat) -> CGFloat { return random() * (max - min) + min } func addNeutron() { let neutron = SKSpriteNode(imageNamed: "neutron.heic") neutron.size = CGSize(width: 20, height: 20) neutron.physicsBody = SKPhysicsBody(rectangleOf: neutron.size) neutron.physicsBody?.isDynamic = true let actualX = random(min: 0, max: size.width) let actualY = random(min: 0, max: size.height) neutron.position = CGPoint(x: actualX, y: actualY) addChild(neutron) let actualDuration = random(min: CGFloat(2.0), max: CGFloat(4.0)) let actualX2 = random(min: 0, max: size.width) let actualY2 = random(min: 0, max: size.height) let actionMove = SKAction.move(to: CGPoint(x: actualX2, y: actualY2), duration: TimeInterval(actualDuration)) let actionMoveDone = SKAction.removeFromParent() neutron.run(SKAction.sequence([actionMove, actionMoveDone])) } }
Replies
2
Boosts
0
Views
1.5k
Activity
Apr ’22