Posts

Post not yet marked as solved
0 Replies
253 Views
Can you access the objects in a struct from outside the struct? So far I have a group of HStacks and VStacks whose embedded objects are all Images(“name”). By definition these Images are fixed in terms of their .position and .size for example. Can I dynamically access these embedded objects from outside the struct? in short, move them ?
Posted
by JohnLove.
Last updated
.
Post not yet marked as solved
2 Replies
263 Views
Where do I place my code to instantiate my Project’s struct code within SwiftUI? As you can see way below, I call: _ = StaticObjects() Within GameScene’s didMove It seems the reason I don’t see the same #Preview image in my GameScene is that I am not explicitly returning a SwiftUI some View within my struct layout. I do know that didMove is really called .. but I just don’t see anything within the Simulator My #Preview works great: The following code appears within GameScene.swift of my Xcode Project: import SpriteKit import SwiftUI struct StaticObjects : View { // some View is returned when our struct is instantiated var body: some View { let theBuildings = ["hotel", "saloon", "watertower", "jail", "farmhouse", "barn"] let theFigures = ["desperado", "sheriff", "space", "space", "horse", "guy"] VStack { HStack(alignment: .bottom) { ForEach(theBuildings, id: \.self) { theBuilding in Image(theBuilding) .resizable() // for rotation .scaledToFit() .zIndex(2) Spacer() } // ForEach } // HStack for theBuildings HStack(alignment: .bottom) { ForEach(theFigures, id: \.self) { theFigure in Image(theFigure) .resizable() // for rotation .frame(width: 120, height: 230) .offset(x: 0.0, y: -50.0) .zIndex(2) Spacer() } // ForEach } // HStack for theFigures // aligns vertically the entire struct to the top Spacer() } // VStack } // body: } // struct StaticObjects /* #Preview { StaticObjects() } */ class GameScene: SKScene, SKPhysicsContactDelegate { override func sceneDidLoad() { super.sceneDidLoad() } // sceneDidLoad override func didMove(to view: SKView) { super.didMove(to:view) physicsWorld.contactDelegate = self _ = StaticObjects() // doesn’t work } // didMove func didBegin(_ contact: SKPhysicsContact) { // ... } // didBegin } // class GameScene
Posted
by JohnLove.
Last updated
.
Post not yet marked as solved
1 Replies
378 Views
12.9 inch iPad Simulator not presenting SpriteNodes correctly for Xcode When I generate my SKScene, I use ourScene.scaleMode = .aspectFill I then display several SKShapeNodes, e.g., let roomWidth = UIScreen.main.bounds.width let roomHeight = UIScreen.main.bounds.height let circleRadius = 30.0 itsStatusNode = SKShapeNode(circleOfRadius: circleRadius) let circleOffsetX = 95.0 let circleOffsetY = 70.0 let circlePosX = roomWidth/2 - circleRadius - circleOffsetX let circlePosY = roomHeight/2 - circleRadius - circleOffsetY itsStatusNode.position = CGPoint(x: circlePosX, y: circlePosY) toScene.addChild(itsStatusNode) The above Code works for all Xcode Simulators: iPad (10th Generation) iPad Air (5th Generation) iPad Pro (11 inch) (4th Generation) iPad Mini (6th Generation) except the iPad (12.9 inch )(6th Generation) For example, these work for all except the 12.9" (landscape) circleOffsetX = 95.0 circleOffsetY = 70.0 (portrait) circleOffsetX = 70.0 circleOffsetY = 95.0 For just the 12.9" these work (landscape) circleOffsetX = 190.0 circleOffsetY = 145.0 (portrait) circleOffsetX = 150.0 circleOffsetY = 190.0 I have seen other reports that point other errors out for just the 12.9 inch Simulator. Or, is this one of many examples when I have to upload the App to a real Device such as my iPad or Apple TV? FWIW, I only have a iPad Mini, not the 12.9 inch version As always, thanks bunches for just reading this.
Posted
by JohnLove.
Last updated
.
Post marked as solved
1 Replies
343 Views
Error = Device orientations are not supported in Mac Catalyst processes Got this error when selecting the Destination = "My Mac (designed for iPad". I tried using the following Code Snippet in my GameViewController, but it did not work. Can anyone provide some guidance?: #if os(iOS) && !targetEnvironment(macCatalyst) // for rotation Landscape <-> Portrait = iOS, // but *not* for Mac (built for iPad) override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() showScene() } // viewDidLayoutSubviews #endif
Posted
by JohnLove.
Last updated
.
Post not yet marked as solved
0 Replies
513 Views
Cannot look at contents of file in Print Queue with Sonoma Before Sonoma, after I selected print in a application, e.g., Word, I could double click on the document stored in the Print Queue and the pages would be displayed. With Sonoma, cannot see file contents?? One last thing pertaining to this Print Queue = I can't delete any of the accumulated "Completed" Jobs .. menu item to delete selected Jobs is dimmed??
Posted
by JohnLove.
Last updated
.
Post marked as solved
2 Replies
833 Views
New after update to Xcode 15: Error processing request from MAD on result: Error Domain=NSOSStatusErrorDomain Code=-128 "Request was canceled" Here is my code which I call within my GameViewController's viewDidLoad(). present(itsPlayerController!, animated:true) { self.itsMoviePlayer?.play() self.itsMovieIsFinished = false } Here is my code which I call at various times via playMovie(movieName: "pose"): func playMovie(movieName: String) { NotificationCenter.default.addObserver(self, selector: #selector(playerDidFinishPlaying), name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: itsPlayerController?.player?.currentItem) present(itsPlayerController!, animated:true) { self.itsMoviePlayer?.play() self.itsMovieIsFinished = false } } // playMovie @objc func playerDidFinishPlaying(note: NSNotification) { self.itsPlayerController?.dismiss(animated:false, completion:nil) nextScene() changeScene() // re-init for next time setupMovie(theMovieName: "pose") } NB: If I do not call playMovie ==> NO ERROR THE PROBLEM = my call to present within playMovie. If I totally comment out present, = NO ERROR If I comment out just the guts of present, other errors are introduced. I have checked the syntax of calling present and I don't see any error there. All the above pertains to the Destination = iPad Mini (6th Generation If the Destination = Apple TV, then we get within GameViewDidLoad Unable to simultaneously satisfy constraints. For both Destinations, the Game runs OK - it's just these Warnings?? HAALP
Posted
by JohnLove.
Last updated
.
Post marked as solved
9 Replies
713 Views
Too Complex to Compile? Ventura 13.4.1 New error after update to Xcode 14.3.1 from 14.3.0 // ... <= -(roomHeight/2 - kFudge) too complex to compile ?? if (playerPosY - playerHeight/2) <= (kFudge - roomHeight/2) { // ... this variation works, the previous one doesn't } kFudge and the other parms are declared Double! within AppDelegate. I don't understand what is suddenly wrong after Xcode update.
Posted
by JohnLove.
Last updated
.
Post not yet marked as solved
0 Replies
478 Views
I have multiple images that at various times I need to replace a target image for a SKSpriteNode. Each of these multiple images has a different size. The target SKSpriteNode has a fixed frame that I want to stay fixed. This target is created via: myTarget = SKSpriteNode(imageNamed: “target”) myTarget.size = CGSize(…) myTarget.physicsBody = SKPhysicsBody(rectangleOf: myTarget.size) How do I resize each of the multiple images so that each fills up the target frame (expand or contract)? Pretend the target is a shoebox and each image is a balloon that expands or contracts to fill the shoebox. I have tried the following that fails, that is, it changes the size of the target to fit the new image .. in short, it does the exact opposite of what I want. let newTexture = SKTexture(imageNamed: newImage) let changeImgAction = SKAction.setTexture(newTexture, resize: true) myTarget.run(changeImgAction) Again, keep frame of myTarget fixed and change size of newTexture to fit the above frame ..
Posted
by JohnLove.
Last updated
.
Post marked as solved
4 Replies
1k Views
Nimbus+ game controller not working with Ventura 13.3 and comparable tvOS Prior to updating these OS' yesterday, my Computer App in the App Store worked. After updating, not working. I have contacted SteelSeries, the mgr of Nimbus+, and they refuse to admit it's their firmware. And I have definitely started up their SteelSeries CG application and looked for a firmware update -- none. Replacement of hardware is not the solution. Any contrary ideas you folk may have would be extremely helpful.
Posted
by JohnLove.
Last updated
.
Post marked as solved
1 Replies
1.1k Views
Specifically the Nimbus+ ... but I tried for a few days a PlayStation Dual Sense ... and the identical problem with just Mac OS Ventura 13.3. One more thing, ZERO problems with my iPhone and your Apple TV. So, the following problem is ONLY with Ventura 13.3 (NOT 13.2 and earlier - just 13.3). Here's the problem .. the Nimbus+ will not stay connected and after about 15 seconds disconnects by itself. The above PlayStation Dual Sense sticks around for about 60 seconds and then disconnects by itself. For the record, I have several times chatted with Nimbus Tech Support. Total Failure, sorry to say. Some chatter out there in Google Land said that the blinking lights on my Nimbus+ show (to him) that the chargeable batteries are "bricked" and need to be reset. If true, then why does my Nimbus+ work great with my iPhone and Apple TV? Just asking ... I'm a computer programmer but I am not a hardware person who can take apart the Nimbus and hit its reset button. There you have it ... any help at all will be appreciated. JL
Posted
by JohnLove.
Last updated
.
Post marked as solved
17 Replies
1.7k Views
Using Swift, how do I continuously test for a GamePad being on/connected? When you build a Browser-based Canvas + Javascript Game, you do the above via: function listenForGamepadConnected() {     window.addEventListener("gamepadconnected", (event) => {                // this is the BIGEE that is always testing     }); }   // listenForGamepadConnected And it definitely works! I cannot find its equivalent in the Xcode/Swift world? I do see the following that’s built into a boilerplate Game that you initially create using Xcode - but it seems that it just looks once, versus continuously:     func ObserveForGameControllers() {                          NotificationCenter.default.addObserver(                     self,                     selector: #selector(connectControllers),                     name: NSNotification.Name.GCControllerDidConnect,                     object: nil)                 NotificationCenter.default.addObserver(                     self,                     selector: #selector(disconnectControllers),                     name: NSNotification.Name.GCControllerDidDisconnect,                     object: nil)             }   // ObserveForGameControllers                  @objc func connectControllers() {                 // Unpause the Game if it is currently paused         self.isPaused = false                 // Used to register the Nimbus Controllers to a specific Player Number         var indexNumber = 0         // Run through each controller currently connected to the system         for controller in GCController.controllers() {                         // Check to see whether it is an extended Game Controller (Such as a Nimbus)             if controller.extendedGamepad != nil {                 print("CONNECTED - Extended Gamepad #\(indexNumber)")                                  controller.playerIndex = GCControllerPlayerIndex.init(rawValue: indexNumber)!                                  indexNumber += 1                 setupControllerControls(controller: controller)             }             else {                 print("CONNECTED - but, NOT an Extended Gamepad #\(indexNumber)")             }                     }             }   // connectControllers          @objc func disconnectControllers() {                 print("DIS-CONNECTED")         // Pause the Game if a controller is disconnected ~ This is mandated by Apple         self.isPaused = true             }   // disconnectControllers I try to call it in a Timer loop, but still does not work:     @objc func testForGamepadIsConnected() {         ObserveForGameControllers         var gamepadOn = !self.isPaused   // does not work             }   // testForGamepadIsConnected     func startTestForGamepad() {         guard (gamepadTimer != nil) else {             gamepadTimer = Timer.scheduledTimer(                                     timeInterval: 1.0,                                     target: self,                                     selector:#selector(testForGamepadIsConnected),                                     userInfo: nil,                                     repeats: true)             return         }     }   // startTestForGamepad     func stopTestForGamepad() {         guard (gamepadTimer == nil) else {             gamepadTimer!.invalidate()             // .invalidate() removes Timer() from gamepadTimer, so reinitialize it.             gamepadTimer = Timer()             return         }     }   // stopTestForGamepad Scoured the Google world, but I’ve come up empty. Would appreciate some genius out there providing what I’m missing. Thanks loads.
Posted
by JohnLove.
Last updated
.
Post not yet marked as solved
1 Replies
712 Views
With Xcode 14.2, had trouble pairing with my Apple TV (latest update). It continuously showed "Not Connected". So, I unpaired my apple tv and now the ATV does not show under Devices and Simulators. My ATV shows as the Target of my Xcode Project My Ventura 13.3 iMac mirrors to my ATV just great, but not my Xcode 14.2. Have turned off my ATV, quit Xcode and Shutdown and then re-started my iMac and no luck. Help desperately needed. Other posts seem to show an identical problem experienced by others.
Posted
by JohnLove.
Last updated
.
Post not yet marked as solved
4 Replies
646 Views
Have received no feedback on: Case-ID: 1777202 March 10th Got automated reply Sent added data as they requested in this reply (seems to be a standard component in such replies). Anyway, 17 days ago. Can anyone check on this ID for me Thanks.
Posted
by JohnLove.
Last updated
.
Post marked as solved
1 Replies
394 Views
Trouble making SKSpriteNode bounce off anotherSKSpriteNode using Bit Masks and func didBegin(..) Here are some brief Code Snippets: For brevity, let's consider 4 SKSpriteNode's The Bit Masks and the .png Strings are defined within AppDelegate, along with: var noCollision: UInt32 = 00000000 var noContact: UInt32 = 00000000 var roomCategory: UInt32 = 00000001 var playerCategory: UInt32 = 00000010 var ballCategory: UInt32 = 00000100 var UCategory: UInt32 = 00001000 Next Snippet appears within GameViewController which calls .addChild for each Node: myRoom = SKSpriteNode(imageNamed: "room.png") myRoom.size = CGSize(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height) myRoom.physicsBody = SKPhysicsBody(rectangleOf: myRoom.size) myRoom.physicsBody?.categoryBitMask = roomCategory myRoom.physicsBody?.contactTestBitMask = noContact myPlayer = SKSpriteNode(imageNamed: "player.png") myPlayer.size = CGSize(width: playerWidth, height: playerHeight) myPlayer.physicsBody = SKPhysicsBody(rectangleOf: myPlayer.size) myPlayer.physicsBody?.categoryBitMask  = playerCategory myPlayer.physicsBody?.collisionBitMask = noCollision myPlayer.physicsBody?.contactTestBitMask = noContact myBall = SKSpriteNode(imageNamed: "ball.png") myBall.size = CGSize(width: ballWidth, height: ballHeight) myBall.physicsBody = SKPhysicsBody(rectangleOf: myBall.size) myBall.physicsBody?.categoryBitMask = ballCategory myBall.physicsBody?.collisionBitMask = noCollision myBall.physicsBody?.contactTestBitMask = roomCategory | UCategory myUStake = SKSpriteNode(imageNamed: "ustake.png") myUStake.size = CGSize(width: U1Width, height: U1Height) myUStake.physicsBody = SKPhysicsBody(rectangleOf: myU1.size) myUStake.physicsBody?.categoryBitMask = UCategory myUStake.physicsBody?.collisionBitMask = noCollision myUStake.physicsBody?.contactTestBitMask = ballCategory Finally, here's my func didBegin func didBegin(_ contact: SKPhysicsContact) {                                                   let bodyAName = contact.bodyA.node?.name      let bodyBName = contact.bodyB.node?.name               let playerHitBall = ((bodyBName == myPlayer.name) && (bodyAName == myBall.name))  ||                          ((bodyAName == myPlayer.name) && (bodyBName == myBall.name))               let ballHitU      = ((bodyBName == myBall.name)   && (bodyAName == myU1.name))    ||                          ((bodyAName == myBall.name)   && (bodyBName == myU1.name))               if playerHitBall {      //     moveBallIfHitsWall()      //     attaBoy()           print("player hit ball")       }       if ballHitU {       //    attaBoy()       //    moveBallIfHitsUStake(theUStake: UStakes[0])           print("ball hit U1")       } }   // didBegin No print statements show in the Debugger. Anybody that has some light to shine on my error or errors would be greatly appreciated. Thanks in advance.
Posted
by JohnLove.
Last updated
.