SpriteKit

RSS for tag

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

Posts under SpriteKit tag

200 Posts

Post

Replies

Boosts

Views

Activity

SpriteKit Crash Only when WatchOS >= 8.X
-[SKLabelNode _isEligibleForFocus]: unrecognized selector sent to instance 0x1164f040 ( 0 CoreFoundation 0x1a90ce68 26D96C7E-9A5C-3F48-9DBA-7AC4B4E0F3FD + 786024 1 libobjc.A.dylib 0x23add390 objc_exception_throw + 56 2 CoreFoundation 0x1a9a04f8 26D96C7E-9A5C-3F48-9DBA-7AC4B4E0F3FD + 1389816 3 UIKitCore 0x1e5b6394 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 11969428 4 CoreFoundation 0x1a860c14 26D96C7E-9A5C-3F48-9DBA-7AC4B4E0F3FD + 80916 5 CoreFoundation 0x1a85efcc _CF_forwarding_prep_0 + 92 6 SpriteKit 0x3cb782f8 B5D8103E-85CD-33A3-BB6D-F318B027A10D + 287480 7 SpriteKit 0x3cbb224c B5D8103E-85CD-33A3-BB6D-F318B027A10D + 524876 8 SpriteKit 0x3cbb2128 B5D8103E-85CD-33A3-BB6D-F318B027A10D + 524584 9 SpriteKit 0x3cb781f8 B5D8103E-85CD-33A3-BB6D-F318B027A10D + 287224 10 SpriteKit 0x3cb96940 B5D8103E-85CD-33A3-BB6D-F318B027A10D + 411968 11 UIKitCore 0x1e15388c C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7370892 12 UIKitCore 0x1e153b44 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7371588 13 UIKitCore 0x1e9474e8 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 15709416 14 UIKitCore 0x1e15388c C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7370892 15 UIKitCore 0x1e153b44 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7371588 16 UIKitCore 0x1e9474e8 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 15709416 17 UIKitCore 0x1e15388c C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7370892 18 UIKitCore 0x1e153b44 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7371588 19 UIKitCore 0x1e9474e8 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 15709416 20 UIKitCore 0x1e15388c C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7370892 21 UIKitCore 0x1e152684 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7366276 22 UIKitCore 0x1e151d74 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7363956 23 UIKitCore 0x1e154768 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7374696 24 UIKitCore 0x1e14a5a8 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7333288 25 UIKitCore 0x1e121d30 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7167280 26 UIKitCore 0x1e121804 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7165956 27 UIKitCore 0x1e121744 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7165764 28 UIKitCore 0x1e122514 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7169300 29 UIKitCore 0x1e12263c C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7169596 30 UIKitCore 0x1e12263c C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7169596 31 UIKitCore 0x1e12263c C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7169596 32 UIKitCore 0x1e12263c C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7169596 33 UIKitCore 0x1e12236c C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7168876 34 UIKitCore 0x1e122c20 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7171104 35 UIKitCore 0x1e1669d4 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7449044 36 UIKitCore 0x1e1667cc C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7448524 37 UIKitCore 0x1e1666a8 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7448232 38 UIKitCore 0x1e157ff8 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7389176 39 UIKitCore 0x1e15bc28 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7404584 40 UIKitCore 0x1dae83a4 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 639908 41 UIKitCore 0x1da52ac8 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 27336 42 UIKitCore 0x1da4f674 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 13940 43 UIKitCore 0x1da52d88 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 28040 44 UIKitCore 0x1da6a550 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 124240 45 CoreFoundation 0x1a85bf5c 26D96C7E-9A5C-3F48-9DBA-7AC4B4E0F3FD + 61276 46 CoreFoundation 0x1a88570c 26D96C7E-9A5C-3F48-9DBA-7AC4B4E0F3FD + 231180 47 CoreFoundation 0x1a8522cc 26D96C7E-9A5C-3F48-9DBA-7AC4B4E0F3FD + 21196 48 CoreFoundation 0x1a89a250 CFRunLoopRunSpecific + 572 49 GraphicsServices 0x3dee19a8 GSEventRunModal + 160 50 UIKitCore 0x1dbff4c4 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 1782980 51 UIKitCore 0x1db9a32c UIApplicationMain + 140 52 WatchKit 0x239bc8a0 WKExtensionMain + 776 53 dyld 0x051d91ec start + 472 )
4
0
1.7k
Mar ’22
How do I change the textures of nodes once they are placed?
I’m currently working on a matching game and when the user touches the nodes (Fruit match cards) I want them to display different images when a user clicks the nodes (Fruit match cards). This is my current code:  import Foundation  import SpriteKit  class EasyScreen: SKScene {         override func didMove(to view: SKView) {          var background = SKSpriteNode(imageNamed: "Easy Screen Background")          let timerText = SKLabelNode(fontNamed: "Arial")      timerText.fontSize = 40     timerText.fontColor = SKColor.white      timerText.position = CGPoint(x: 20, y: 400)      timerText.zPosition = 1     var counter:Int = 120                timerText.run(SKAction.repeatForever(SKAction.sequence([SKAction.run {              counter-=1       timerText.text = " Time: (counter)"       print("(counter)")          if counter <= 0{            let newScene = TryAgainScreen(fileNamed: "Try Again Screen")       newScene?.scaleMode = .aspectFill       self.view?.presentScene(newScene)                }       },SKAction.wait(forDuration: 1)])))                 background.position = CGPoint(x: 0, y: 0)     background.size.width = self.size.width     background.size.height = self.size.height     background.anchorPoint = CGPoint(x: 0.5,y: 0.5)               let matchCardOne = SKSpriteNode(imageNamed: "Fruit Match Card")     let matchCardTwo = SKSpriteNode(imageNamed: "Fruit Match Card")     let matchCardThree = SKSpriteNode(imageNamed: "Fruit Match Card")     let matchCardFour = SKSpriteNode(imageNamed: "Fruit Match Card")                  matchCardOne.name = "FruitMatchCard1"     matchCardTwo.name = "FruitMatchCard2"     matchCardThree.name = "FruitMatchCard3"     matchCardFour.name = "FruitMatchCard4"          matchCardOne.size = CGSize(width: 150, height: 300)     matchCardTwo.size = CGSize(width: 150, height: 300)     matchCardThree.size = CGSize(width: 150, height: 300)     matchCardFour.size = CGSize(width: 150, height: 300)               matchCardOne.zPosition = 1     matchCardTwo.zPosition = 1     matchCardThree.zPosition = 1     matchCardFour.zPosition = 1               matchCardOne.anchorPoint = CGPoint(x: 0.5, y: 0.5)     matchCardTwo.anchorPoint = CGPoint(x: 0.5, y: 0.5)     matchCardThree.anchorPoint = CGPoint(x: 0.5, y: 0.5)     matchCardFour.anchorPoint = CGPoint(x: 0.5, y: 0.5)               matchCardOne.position = CGPoint(x: -125, y: 60)     matchCardTwo.position = CGPoint(x: -125, y: -260)     matchCardThree.position = CGPoint(x: 70, y: 60)     matchCardFour.position = CGPoint(x: 70 , y: -260)          addChild(background)     addChild(matchCardOne)     addChild(matchCardTwo)     addChild(matchCardThree)     addChild(matchCardFour)     addChild(timerText)        } override func touchesBegan(_ touches: Set, with event: UIEvent?) {         self.view?.isMultipleTouchEnabled = false      let touch = touches.first   let positionInScene = touch!.location(in: self)   let touchedCardOneNode = self.atPoint(positionInScene)      if let name = touchedCardOneNode.name {          if name == "FruitMatchCard1" {           let newTexture = SKTexture(imageNamed: "Apple")       FruitMatchCard1.init(texture: newTexture)          }      }      let touchTwo = touches.first     let positionInSceneTwo = touch!.location(in: self)     let touchedCardTwoNode = self.atPoint(positionInScene)           if let name = touchedCardTwoNode.name {               if name == "FruitMatchCard2" {                 FruitMatchCard2.init(imageNamed: "Banana")              }          }        let touchThree = touches.first       let positionInSceneThree = touch!.location(in: self)      let touchedCardThreeNode = self.atPoint(positionInScene)            if let name = touchedCardThreeNode.name {                if name == "FruitMatchCard3" {                            FruitMatchCard3.init(imageNamed: "Apple")                }            }        let touchFour = touches.first   let positionInSceneFour = touch!.location(in: self)   let touchedCardFourNode = self.atPoint(positionInScene)      if let name = touchedCardFourNode.name {         if name == "FruitMatchCard4" {                 FruitMatchCard4.init(imageNamed: "Banana")          }      }        } override func touchesEnded(_ touches: Set, with event: UIEvent?) {             } I’m trying to change the textures of the nodes in this part of the code. Inside the “if name == “FruitMatchCard” { } “ part of the code. However, when I launch the Xcode simulator the node’s textures aren't changing. Any advice on how I can do this? Thanks!
1
0
999
Mar ’22
Memory bug with Swifts new Concurrency and SpriteKit
We noticed when using async await with SpriteKit run function. Self is retained until run action is completed which can cause memory leak.   Task {             try? await Task.sleep(nanoseconds: 2 * NSEC_PER_SEC)             await controller.startIntro()             print("intro done")         } If you deallocate controller, memory won't be released until await is not completed.  calling:  scene.removeAllActions() cause memory leak.  Here is project reproducing steps with possible workarounds:  https://github.com/maradic/SpriteKitConcurrencyBug Is this SpriteKit bug or am I doing something wrong?
0
0
1.5k
Feb ’22
Notification Banners Freeze Game
Hey everyone,In one of my apps I've been working on where SKShapeNodes fall from the top to the bottom via gravity, if the player recieves a notification in iOS 9 (such as a text message), the game temporarily freezes for around 1 second and then resumes but the nodes have jumped ahead, as if the nodes are still falling but failing to display for that second. Has anyone else come across this? Is there a solution or is it just best to hold out hope for iOS 10? Unfortunately this issue makes the game near unplayable 😟Cheers
2
0
1.2k
Feb ’22
Sort of missing tab in spritekit layout
Im learning to use spritekit, first-project kind of newbie, and on various tutorials I've seen that there is a tab on the right column, on the bottom, with a menu that helps import visual assets quickly into a gamescene. Upon creating my first project I can't seem to find this tab nor a way to add it to my project; under the "Custom shader uniforms" my right-most column seems empty, unlike what I've seen on tutorials. Since this 'tab' doesn't seem to have a title I'm unsure of what I'm even looking for! This is how my new spritekit scene looks like: This is a screenshot from a tutorial where an asset importer kind of tab can be seen: Any help is very much appreciated!!!
0
0
747
Feb ’22
my segue transition goes upward instead of sideways and does not completely cover screen
In my app using storyboard and spritekit developed in Xcode 12.5.1 uses segue connected button to bring up another storyboard which presents a scene and show a sprite. The segue sequence triggered by the use pressing the Play button and running the segue shows an upward transition and the scene with the sprite that when clicked animates that sprite. My problem is I was getting two events that are causing me issues. The first is that I was expecting a sidewards transition for the Show segue. and second that the scene only covers 2 thirds on the screen not all of it. Screenshots of. Xcode showing main storyboard and segue connections, simulator app Settings, app Game initial view and app Game with sprite animated. Anyone any hints for me for explanation of the first event and how to resolve the second which is spoiling my development time?
2
0
842
Feb ’22
Failure to unarchive a sprite kit particle file
Hi all,I'm having trouble in trying to access the content of a sprite kit particle file in a way that conforms with the recent deprecation of several functions in NSKeyedArchiver.Briefly, my project contains a file named "ParticleSmoke.sks", which I used to access easily with the following lines of code: NSString *smokePath = [[NSBundle mainBundle] pathForResource:@"ParticleSmoke" ofType:@"sks"]; SKEmitterNode* smoke = [NSKeyedUnarchiver unarchiveObjectWithFile:smokePath];now that the unarchiving function has been deprecated, I fail to use the (poorly documented) unarchivedObjectOfClass function. Especially, the code below returns nil. NSString *smokePath = [[NSBundle mainBundle] pathForResource:@"ParticleSmoke" ofType:@"sks"]; NSData* smokeData = [NSData dataWithContentsOfFile:smokePath]; NSError* error=nil; Class cls = [SKEmitterNode class]; SKEmitterNode* smoke = (SKEmitterNode*)[NSKeyedUnarchiver unarchivedObjectOfClass:cls fromData:smokeData error:&amp;error];Unexpectedly, the content of "error" (code 4864) was@"NSDebugDescription" : @"value for key 'NS.objects' was of unexpected class 'NSColor'. Allowed classes are '{(\n SKKeyframeSequence,\n NSArray,\n NSNumber,\n NSMutableArray\n)}'."Has anyone an idea to fix this issue?Thanks for your help....
2
0
1.9k
Jan ’22
xcode12 spritekit image shown as red X
I am trying to get a simple animated sprite image in a very basic game using SpriteKit and Xcode 12. I am creating an skspritenode with image named and setting its position form the touch point and adding it as a child but a red X image is shown on the simulator of iPhone 8 Plus. I have attached screenshots. Can someone help me with this?
2
0
933
Jan ’22
It is writeing a problem"Editor placeholder in source file" and i down't now what to do now
Im programmin a plong game import SpriteKit import GameplayKit class GameScene: SKScene {     var ball = SKSpriteNode()     var enemy = SKSpriteNode()     var main = SKSpriteNode()     override func didMove(to view: SKView) {         ball = self.childNode(withName: "ball") as! SKSpriteNode         enemy = self.childNode(withName: "enemy") as! SKSpriteNode         main = self.childNode(withName: "main") as! SKSpriteNode                  ball.physicsBody?.applyImpulse(CGVector(dx: -20, dy: -20))                  let border = SKPhysicsBody (edgeLoopFrom: self.frame)         border.friction = 0         border.restitution = 1         self.physicsBody = border     }     override func touchesBegan(_ touches: Set, with event: UIEvent?) {     for touch in touches {             let location = touch.location(in: self)                      main.run (SKAction.moveTo(x: location.x, duration: 0.2))                      }     }     override func touchesMoved(_ touches: Set, with event: UIEvent?) {     for touch in touches {             let location = touch.location(in: self)                      main.run (SKAction.moveTo(x: location.x, duration: 0.2))                      }     }          override func update(_ currentTime: TimeInterval) {         enemy.run(SKAction.moveTo(x: ball.position.x, duration: 1.0))     } } and it comms a problem "Editor placeholder in source file" what i can do now??
0
0
1.1k
Jan ’22
Xcode 12.5.1 SpriteKit SkScene tile set images not showing
When I start my project the tile added to my SKScene using the editor do not appear until after I have clicked on the tiles that was selected in the scene setup. Anyone any ideas why> Also should these tiles be in the list shown to the left of the scene as those sprites (not part of the tileset) I dragged into the scene are. I have attached screen shots of at start and after clicking the tiles.
1
0
702
Jan ’22
Will this be your last SpriteKit project?
The project I'm currently working on will be my last SpriteKit project. With about 14k lines of code I can't afford to switch to another library so I'm stuck for now. I'll never make the same mistake again and rely on this framework though.I had also started sketching out other projects with SpriteKit but will abandon all of them and rebuild with other tools.With all the problems SpriteKit has in iOS 9 and Apple's lack of communication about the issue, have you decided to abandon the framework as well?
19
0
8.8k
Jan ’22
Help with SpritKit's Tile Set in SwiftUI. Looking for suggestions
I wanted to build a game for my class like "UniWar: Multiplayer Strategy." It is a hexagonal tile 2d strategy game. Everywhere I search online, everything points to using SpriteKit and using the tile sets to accomplish what I want. The problem I am running into is that there is very little if not poor examples online of using Tile Sets and SpriteKit (or maybe they are super good but my novice skills is getting in the way). Every tutorial I have found is either 6 years old and is unrecognizable or Apple Documentation that tends to explain what it is but not how to use it. I should mention a couple things, one, yes, I am a novice swift programmer and, two, I learn best by doing not by being told (so for example, someone showing me how to use it helps a lot more than "use this code"). I really want to learn so does anyone have some suggestions for learning Tile Sets and SpriteKit in general? P.S. I am also not above a course that costs something (I have already searched Udemy for a course on this but couldn't find one)
1
0
627
Jan ’22
Unable to Install Tap on Input Node in MacOS for Live Audio Speech Recognition
I'm developing a game that will use speech recognition to execute various commands. I am using code from Apple's Recognizing Speech in Live Audio documentation page. When I run this in a Swift Playground, it works just fine. However, when I make a SpriteKit game application (basic setup from Xcode's "New Project" menu option), I get the following error: required condition is false: IsFormatSampleRateAndChannelCountValid(hwFormat) Upon further research, it appears that my input node has no channels. The following is the relevant portion of my code, along with debug output: let inputNode = audioEngine.inputNode print("Number of inputs: \(inputNode.numberOfInputs)") // 1 print("Input Format: \(inputNode.inputFormat(forBus: 0))") // <AVAudioFormat 0x600001bcf200: 0 ch, 0 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved> let channelCount = inputNode.inputFormat(forBus: 0).channelCount print("Channel Count: \(channelCount)") // 0 <== Agrees with the inputFormat output listed previously // Configure the microphone input. print("Number of outputs: \(inputNode.numberOfOutputs)") // 1 let recordingFormat = inputNode.outputFormat(forBus: 0) print("Output Format: \(recordingFormat)") // <AVAudioFormat 0x600001bf3160: 2 ch, 44100 Hz, Float32, non-inter> inputNode.installTap(onBus: 0, bufferSize: 256, format: recordingFormat, block: audioTap) // <== This is where the error occurs. // NOTE: 'audioTap' is a function defined in this class. Using this defined function instead of an inline, anonymous function. The code snippet is included in the game's AppDelegate class (which includes import statements for Cocoa, AVFoundation, and Speech), and executes during its applicationDidFinishLaunching function. I'm having trouble understanding why Playground works, but a game app doesn't work. Do I need to do something specific to get the application to recognize the microphone? NOTE: This if for MacOS, NOT iOS. While the "How To" documentation cited earlier indicates iOS, Apple stated at WWDC19 that it is now supported on the MacOS. NOTE: I have included the NSSpeechRecognitionUsageDescription key in the applications plist, and successfully acknowledged the authorization request for the microphone.
1
0
2.4k
Dec ’21
SpriteKit SKScene Can't Find SKS File
I'm toying around with SpriteKit and using SKS files to construct scenes. I've started with the stock Game project and added one extra SKS file and a class to go along with it. My class will attempt to load the SKS file to build its scene just like the stock files do. However, when I go to the GameViewController and actually try to use my class, I get a runtime error that my SKS file can't be found. I've verified that the SKS file is in the project, is part of the bundle, is visible at runtime from within the bundle, but my class that uses the SKScene initializer to load the file can't see it and I'm not sure why.
0
0
497
Dec ’21
SpriteKit Crash Only when WatchOS >= 8.X
-[SKLabelNode _isEligibleForFocus]: unrecognized selector sent to instance 0x1164f040 ( 0 CoreFoundation 0x1a90ce68 26D96C7E-9A5C-3F48-9DBA-7AC4B4E0F3FD + 786024 1 libobjc.A.dylib 0x23add390 objc_exception_throw + 56 2 CoreFoundation 0x1a9a04f8 26D96C7E-9A5C-3F48-9DBA-7AC4B4E0F3FD + 1389816 3 UIKitCore 0x1e5b6394 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 11969428 4 CoreFoundation 0x1a860c14 26D96C7E-9A5C-3F48-9DBA-7AC4B4E0F3FD + 80916 5 CoreFoundation 0x1a85efcc _CF_forwarding_prep_0 + 92 6 SpriteKit 0x3cb782f8 B5D8103E-85CD-33A3-BB6D-F318B027A10D + 287480 7 SpriteKit 0x3cbb224c B5D8103E-85CD-33A3-BB6D-F318B027A10D + 524876 8 SpriteKit 0x3cbb2128 B5D8103E-85CD-33A3-BB6D-F318B027A10D + 524584 9 SpriteKit 0x3cb781f8 B5D8103E-85CD-33A3-BB6D-F318B027A10D + 287224 10 SpriteKit 0x3cb96940 B5D8103E-85CD-33A3-BB6D-F318B027A10D + 411968 11 UIKitCore 0x1e15388c C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7370892 12 UIKitCore 0x1e153b44 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7371588 13 UIKitCore 0x1e9474e8 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 15709416 14 UIKitCore 0x1e15388c C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7370892 15 UIKitCore 0x1e153b44 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7371588 16 UIKitCore 0x1e9474e8 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 15709416 17 UIKitCore 0x1e15388c C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7370892 18 UIKitCore 0x1e153b44 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7371588 19 UIKitCore 0x1e9474e8 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 15709416 20 UIKitCore 0x1e15388c C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7370892 21 UIKitCore 0x1e152684 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7366276 22 UIKitCore 0x1e151d74 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7363956 23 UIKitCore 0x1e154768 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7374696 24 UIKitCore 0x1e14a5a8 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7333288 25 UIKitCore 0x1e121d30 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7167280 26 UIKitCore 0x1e121804 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7165956 27 UIKitCore 0x1e121744 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7165764 28 UIKitCore 0x1e122514 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7169300 29 UIKitCore 0x1e12263c C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7169596 30 UIKitCore 0x1e12263c C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7169596 31 UIKitCore 0x1e12263c C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7169596 32 UIKitCore 0x1e12263c C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7169596 33 UIKitCore 0x1e12236c C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7168876 34 UIKitCore 0x1e122c20 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7171104 35 UIKitCore 0x1e1669d4 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7449044 36 UIKitCore 0x1e1667cc C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7448524 37 UIKitCore 0x1e1666a8 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7448232 38 UIKitCore 0x1e157ff8 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7389176 39 UIKitCore 0x1e15bc28 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 7404584 40 UIKitCore 0x1dae83a4 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 639908 41 UIKitCore 0x1da52ac8 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 27336 42 UIKitCore 0x1da4f674 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 13940 43 UIKitCore 0x1da52d88 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 28040 44 UIKitCore 0x1da6a550 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 124240 45 CoreFoundation 0x1a85bf5c 26D96C7E-9A5C-3F48-9DBA-7AC4B4E0F3FD + 61276 46 CoreFoundation 0x1a88570c 26D96C7E-9A5C-3F48-9DBA-7AC4B4E0F3FD + 231180 47 CoreFoundation 0x1a8522cc 26D96C7E-9A5C-3F48-9DBA-7AC4B4E0F3FD + 21196 48 CoreFoundation 0x1a89a250 CFRunLoopRunSpecific + 572 49 GraphicsServices 0x3dee19a8 GSEventRunModal + 160 50 UIKitCore 0x1dbff4c4 C3A646A8-7F5C-3446-A1A5-D8692AB71AC3 + 1782980 51 UIKitCore 0x1db9a32c UIApplicationMain + 140 52 WatchKit 0x239bc8a0 WKExtensionMain + 776 53 dyld 0x051d91ec start + 472 )
Replies
4
Boosts
0
Views
1.7k
Activity
Mar ’22
SwiftUI on the iPad: Build the interactive book on the iPad
How can I develop Children interactive Book for iPad with SwiftUI?
Replies
0
Boosts
0
Views
977
Activity
Mar ’22
How do I change the textures of nodes once they are placed?
I’m currently working on a matching game and when the user touches the nodes (Fruit match cards) I want them to display different images when a user clicks the nodes (Fruit match cards). This is my current code:  import Foundation  import SpriteKit  class EasyScreen: SKScene {         override func didMove(to view: SKView) {          var background = SKSpriteNode(imageNamed: "Easy Screen Background")          let timerText = SKLabelNode(fontNamed: "Arial")      timerText.fontSize = 40     timerText.fontColor = SKColor.white      timerText.position = CGPoint(x: 20, y: 400)      timerText.zPosition = 1     var counter:Int = 120                timerText.run(SKAction.repeatForever(SKAction.sequence([SKAction.run {              counter-=1       timerText.text = " Time: (counter)"       print("(counter)")          if counter <= 0{            let newScene = TryAgainScreen(fileNamed: "Try Again Screen")       newScene?.scaleMode = .aspectFill       self.view?.presentScene(newScene)                }       },SKAction.wait(forDuration: 1)])))                 background.position = CGPoint(x: 0, y: 0)     background.size.width = self.size.width     background.size.height = self.size.height     background.anchorPoint = CGPoint(x: 0.5,y: 0.5)               let matchCardOne = SKSpriteNode(imageNamed: "Fruit Match Card")     let matchCardTwo = SKSpriteNode(imageNamed: "Fruit Match Card")     let matchCardThree = SKSpriteNode(imageNamed: "Fruit Match Card")     let matchCardFour = SKSpriteNode(imageNamed: "Fruit Match Card")                  matchCardOne.name = "FruitMatchCard1"     matchCardTwo.name = "FruitMatchCard2"     matchCardThree.name = "FruitMatchCard3"     matchCardFour.name = "FruitMatchCard4"          matchCardOne.size = CGSize(width: 150, height: 300)     matchCardTwo.size = CGSize(width: 150, height: 300)     matchCardThree.size = CGSize(width: 150, height: 300)     matchCardFour.size = CGSize(width: 150, height: 300)               matchCardOne.zPosition = 1     matchCardTwo.zPosition = 1     matchCardThree.zPosition = 1     matchCardFour.zPosition = 1               matchCardOne.anchorPoint = CGPoint(x: 0.5, y: 0.5)     matchCardTwo.anchorPoint = CGPoint(x: 0.5, y: 0.5)     matchCardThree.anchorPoint = CGPoint(x: 0.5, y: 0.5)     matchCardFour.anchorPoint = CGPoint(x: 0.5, y: 0.5)               matchCardOne.position = CGPoint(x: -125, y: 60)     matchCardTwo.position = CGPoint(x: -125, y: -260)     matchCardThree.position = CGPoint(x: 70, y: 60)     matchCardFour.position = CGPoint(x: 70 , y: -260)          addChild(background)     addChild(matchCardOne)     addChild(matchCardTwo)     addChild(matchCardThree)     addChild(matchCardFour)     addChild(timerText)        } override func touchesBegan(_ touches: Set, with event: UIEvent?) {         self.view?.isMultipleTouchEnabled = false      let touch = touches.first   let positionInScene = touch!.location(in: self)   let touchedCardOneNode = self.atPoint(positionInScene)      if let name = touchedCardOneNode.name {          if name == "FruitMatchCard1" {           let newTexture = SKTexture(imageNamed: "Apple")       FruitMatchCard1.init(texture: newTexture)          }      }      let touchTwo = touches.first     let positionInSceneTwo = touch!.location(in: self)     let touchedCardTwoNode = self.atPoint(positionInScene)           if let name = touchedCardTwoNode.name {               if name == "FruitMatchCard2" {                 FruitMatchCard2.init(imageNamed: "Banana")              }          }        let touchThree = touches.first       let positionInSceneThree = touch!.location(in: self)      let touchedCardThreeNode = self.atPoint(positionInScene)            if let name = touchedCardThreeNode.name {                if name == "FruitMatchCard3" {                            FruitMatchCard3.init(imageNamed: "Apple")                }            }        let touchFour = touches.first   let positionInSceneFour = touch!.location(in: self)   let touchedCardFourNode = self.atPoint(positionInScene)      if let name = touchedCardFourNode.name {         if name == "FruitMatchCard4" {                 FruitMatchCard4.init(imageNamed: "Banana")          }      }        } override func touchesEnded(_ touches: Set, with event: UIEvent?) {             } I’m trying to change the textures of the nodes in this part of the code. Inside the “if name == “FruitMatchCard” { } “ part of the code. However, when I launch the Xcode simulator the node’s textures aren't changing. Any advice on how I can do this? Thanks!
Replies
1
Boosts
0
Views
999
Activity
Mar ’22
Memory bug with Swifts new Concurrency and SpriteKit
We noticed when using async await with SpriteKit run function. Self is retained until run action is completed which can cause memory leak.   Task {             try? await Task.sleep(nanoseconds: 2 * NSEC_PER_SEC)             await controller.startIntro()             print("intro done")         } If you deallocate controller, memory won't be released until await is not completed.  calling:  scene.removeAllActions() cause memory leak.  Here is project reproducing steps with possible workarounds:  https://github.com/maradic/SpriteKitConcurrencyBug Is this SpriteKit bug or am I doing something wrong?
Replies
0
Boosts
0
Views
1.5k
Activity
Feb ’22
Notification Banners Freeze Game
Hey everyone,In one of my apps I've been working on where SKShapeNodes fall from the top to the bottom via gravity, if the player recieves a notification in iOS 9 (such as a text message), the game temporarily freezes for around 1 second and then resumes but the nodes have jumped ahead, as if the nodes are still falling but failing to display for that second. Has anyone else come across this? Is there a solution or is it just best to hold out hope for iOS 10? Unfortunately this issue makes the game near unplayable 😟Cheers
Replies
2
Boosts
0
Views
1.2k
Activity
Feb ’22
Sort of missing tab in spritekit layout
Im learning to use spritekit, first-project kind of newbie, and on various tutorials I've seen that there is a tab on the right column, on the bottom, with a menu that helps import visual assets quickly into a gamescene. Upon creating my first project I can't seem to find this tab nor a way to add it to my project; under the "Custom shader uniforms" my right-most column seems empty, unlike what I've seen on tutorials. Since this 'tab' doesn't seem to have a title I'm unsure of what I'm even looking for! This is how my new spritekit scene looks like: This is a screenshot from a tutorial where an asset importer kind of tab can be seen: Any help is very much appreciated!!!
Replies
0
Boosts
0
Views
747
Activity
Feb ’22
my segue transition goes upward instead of sideways and does not completely cover screen
In my app using storyboard and spritekit developed in Xcode 12.5.1 uses segue connected button to bring up another storyboard which presents a scene and show a sprite. The segue sequence triggered by the use pressing the Play button and running the segue shows an upward transition and the scene with the sprite that when clicked animates that sprite. My problem is I was getting two events that are causing me issues. The first is that I was expecting a sidewards transition for the Show segue. and second that the scene only covers 2 thirds on the screen not all of it. Screenshots of. Xcode showing main storyboard and segue connections, simulator app Settings, app Game initial view and app Game with sprite animated. Anyone any hints for me for explanation of the first event and how to resolve the second which is spoiling my development time?
Replies
2
Boosts
0
Views
842
Activity
Feb ’22
Can i use spritekit without xcode ?
Can i use spritekit without xcode and just using visual studio code ?
Replies
1
Boosts
0
Views
869
Activity
Jan ’22
Failure to unarchive a sprite kit particle file
Hi all,I'm having trouble in trying to access the content of a sprite kit particle file in a way that conforms with the recent deprecation of several functions in NSKeyedArchiver.Briefly, my project contains a file named "ParticleSmoke.sks", which I used to access easily with the following lines of code: NSString *smokePath = [[NSBundle mainBundle] pathForResource:@"ParticleSmoke" ofType:@"sks"]; SKEmitterNode* smoke = [NSKeyedUnarchiver unarchiveObjectWithFile:smokePath];now that the unarchiving function has been deprecated, I fail to use the (poorly documented) unarchivedObjectOfClass function. Especially, the code below returns nil. NSString *smokePath = [[NSBundle mainBundle] pathForResource:@"ParticleSmoke" ofType:@"sks"]; NSData* smokeData = [NSData dataWithContentsOfFile:smokePath]; NSError* error=nil; Class cls = [SKEmitterNode class]; SKEmitterNode* smoke = (SKEmitterNode*)[NSKeyedUnarchiver unarchivedObjectOfClass:cls fromData:smokeData error:&amp;error];Unexpectedly, the content of "error" (code 4864) was@"NSDebugDescription" : @"value for key 'NS.objects' was of unexpected class 'NSColor'. Allowed classes are '{(\n SKKeyframeSequence,\n NSArray,\n NSNumber,\n NSMutableArray\n)}'."Has anyone an idea to fix this issue?Thanks for your help....
Replies
2
Boosts
0
Views
1.9k
Activity
Jan ’22
xcode12 spritekit image shown as red X
I am trying to get a simple animated sprite image in a very basic game using SpriteKit and Xcode 12. I am creating an skspritenode with image named and setting its position form the touch point and adding it as a child but a red X image is shown on the simulator of iPhone 8 Plus. I have attached screenshots. Can someone help me with this?
Replies
2
Boosts
0
Views
933
Activity
Jan ’22
It is writeing a problem"Editor placeholder in source file" and i down't now what to do now
Im programmin a plong game import SpriteKit import GameplayKit class GameScene: SKScene {     var ball = SKSpriteNode()     var enemy = SKSpriteNode()     var main = SKSpriteNode()     override func didMove(to view: SKView) {         ball = self.childNode(withName: "ball") as! SKSpriteNode         enemy = self.childNode(withName: "enemy") as! SKSpriteNode         main = self.childNode(withName: "main") as! SKSpriteNode                  ball.physicsBody?.applyImpulse(CGVector(dx: -20, dy: -20))                  let border = SKPhysicsBody (edgeLoopFrom: self.frame)         border.friction = 0         border.restitution = 1         self.physicsBody = border     }     override func touchesBegan(_ touches: Set, with event: UIEvent?) {     for touch in touches {             let location = touch.location(in: self)                      main.run (SKAction.moveTo(x: location.x, duration: 0.2))                      }     }     override func touchesMoved(_ touches: Set, with event: UIEvent?) {     for touch in touches {             let location = touch.location(in: self)                      main.run (SKAction.moveTo(x: location.x, duration: 0.2))                      }     }          override func update(_ currentTime: TimeInterval) {         enemy.run(SKAction.moveTo(x: ball.position.x, duration: 1.0))     } } and it comms a problem "Editor placeholder in source file" what i can do now??
Replies
0
Boosts
0
Views
1.1k
Activity
Jan ’22
is there a way to make physics body border line more visible
I am having problems with verifying the SKPhysicsBody setup which is not working. I am having difficulty seeing the PhysicsBody border line in the scene. Is there any way of making the border bigger, different colour, etc?
Replies
1
Boosts
0
Views
574
Activity
Jan ’22
Xcode 12.5.1 SKTexture error loading image resource
I have not been able to find a solution to this problem. Screenshots attached for run error, asset setup, code used to load image. Anyone any hints for me on this?
Replies
1
Boosts
0
Views
782
Activity
Jan ’22
Xcode 12.5.1 SpriteKit SkScene tile set images not showing
When I start my project the tile added to my SKScene using the editor do not appear until after I have clicked on the tiles that was selected in the scene setup. Anyone any ideas why> Also should these tiles be in the list shown to the left of the scene as those sprites (not part of the tileset) I dragged into the scene are. I have attached screen shots of at start and after clicking the tiles.
Replies
1
Boosts
0
Views
702
Activity
Jan ’22
xcode 12.5.1 SpriteKit scene addchild fails reason already present
Using Xcode 12.5.1 and getting uncaught exception when trying to add child to the scene. Attached screenshot shows the code being used and output containing the prints data and the error. Anyone any ideas for me.
Replies
5
Boosts
0
Views
818
Activity
Jan ’22
Will this be your last SpriteKit project?
The project I'm currently working on will be my last SpriteKit project. With about 14k lines of code I can't afford to switch to another library so I'm stuck for now. I'll never make the same mistake again and rely on this framework though.I had also started sketching out other projects with SpriteKit but will abandon all of them and rebuild with other tools.With all the problems SpriteKit has in iOS 9 and Apple's lack of communication about the issue, have you decided to abandon the framework as well?
Replies
19
Boosts
0
Views
8.8k
Activity
Jan ’22
Help with SpritKit's Tile Set in SwiftUI. Looking for suggestions
I wanted to build a game for my class like "UniWar: Multiplayer Strategy." It is a hexagonal tile 2d strategy game. Everywhere I search online, everything points to using SpriteKit and using the tile sets to accomplish what I want. The problem I am running into is that there is very little if not poor examples online of using Tile Sets and SpriteKit (or maybe they are super good but my novice skills is getting in the way). Every tutorial I have found is either 6 years old and is unrecognizable or Apple Documentation that tends to explain what it is but not how to use it. I should mention a couple things, one, yes, I am a novice swift programmer and, two, I learn best by doing not by being told (so for example, someone showing me how to use it helps a lot more than "use this code"). I really want to learn so does anyone have some suggestions for learning Tile Sets and SpriteKit in general? P.S. I am also not above a course that costs something (I have already searched Udemy for a course on this but couldn't find one)
Replies
1
Boosts
0
Views
627
Activity
Jan ’22
Unable to Install Tap on Input Node in MacOS for Live Audio Speech Recognition
I'm developing a game that will use speech recognition to execute various commands. I am using code from Apple's Recognizing Speech in Live Audio documentation page. When I run this in a Swift Playground, it works just fine. However, when I make a SpriteKit game application (basic setup from Xcode's "New Project" menu option), I get the following error: required condition is false: IsFormatSampleRateAndChannelCountValid(hwFormat) Upon further research, it appears that my input node has no channels. The following is the relevant portion of my code, along with debug output: let inputNode = audioEngine.inputNode print("Number of inputs: \(inputNode.numberOfInputs)") // 1 print("Input Format: \(inputNode.inputFormat(forBus: 0))") // <AVAudioFormat 0x600001bcf200: 0 ch, 0 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved> let channelCount = inputNode.inputFormat(forBus: 0).channelCount print("Channel Count: \(channelCount)") // 0 <== Agrees with the inputFormat output listed previously // Configure the microphone input. print("Number of outputs: \(inputNode.numberOfOutputs)") // 1 let recordingFormat = inputNode.outputFormat(forBus: 0) print("Output Format: \(recordingFormat)") // <AVAudioFormat 0x600001bf3160: 2 ch, 44100 Hz, Float32, non-inter> inputNode.installTap(onBus: 0, bufferSize: 256, format: recordingFormat, block: audioTap) // <== This is where the error occurs. // NOTE: 'audioTap' is a function defined in this class. Using this defined function instead of an inline, anonymous function. The code snippet is included in the game's AppDelegate class (which includes import statements for Cocoa, AVFoundation, and Speech), and executes during its applicationDidFinishLaunching function. I'm having trouble understanding why Playground works, but a game app doesn't work. Do I need to do something specific to get the application to recognize the microphone? NOTE: This if for MacOS, NOT iOS. While the "How To" documentation cited earlier indicates iOS, Apple stated at WWDC19 that it is now supported on the MacOS. NOTE: I have included the NSSpeechRecognitionUsageDescription key in the applications plist, and successfully acknowledged the authorization request for the microphone.
Replies
1
Boosts
0
Views
2.4k
Activity
Dec ’21
SpriteKit SKScene Can't Find SKS File
I'm toying around with SpriteKit and using SKS files to construct scenes. I've started with the stock Game project and added one extra SKS file and a class to go along with it. My class will attempt to load the SKS file to build its scene just like the stock files do. However, when I go to the GameViewController and actually try to use my class, I get a runtime error that my SKS file can't be found. I've verified that the SKS file is in the project, is part of the bundle, is visible at runtime from within the bundle, but my class that uses the SKScene initializer to load the file can't see it and I'm not sure why.
Replies
0
Boosts
0
Views
497
Activity
Dec ’21
Is there prefersPointerLocked for NSViewController?
How does one lock the pointer on the macOS using an NSViewController with SpriteKit and GameController. On iOS we can use the prefersPointerLocked solution from WWDC2020. https://developer.apple.com/videos/play/wwdc2020/10617/
Replies
0
Boosts
0
Views
501
Activity
Dec ’21