Post

Replies

Boosts

Views

Activity

Reply to What are the specs requirement for Mac developing for iPhones, iPads, etc?
Oh I tried searching. But they keywords made so many different types of questions popup.Anyway, thanks for the answer, off to buy one now...refurbished, who wants to plunk down THAT much money in this current economy.If I mask a follow up: I'm now sure the difference between XCode and SWift. Is one compiler and one an IE? Do I need both, or have to chose one? I've tried googling this answer but wow....can't find a clear answer. The one main link that popped up seemed to be what I was lookin for, but it was a dead link.And not to be a nudge, what would be the 2 or 3 books that you would recommend for a starter? I've been programming forever, but always on the PC side. Should sayed with it when I tried switching 10 years ago but gave up for other personal reasons.Thanks again
Apr ’20
Reply to Aspiring Developer
I realize you have this checked off as resolved but I'm in the same boat as you and I found two people who speak slowly and really explain what's going on. They channels on YouTube. CodeWithChris Matt Heaney Chris has many video tutorials on specifics: i.e. Logic, Conditionals, Functions, Classes,.DataTypes, etc. And Matt has a 7 video tutorial on building a complete game. It gave me a great view on where to start, how to connect things, etc. etc. Good luck to everyone.
Jul ’20
Reply to Launch Screen in SwiftUI
My understanding, and I am new to Xcode/Swift, is that you can't control how long the LaunchScreen.storyboard is up. As soon as your app is loaded and ready to go it goes to your first scene. The tutorials I have watched on YouTube... Matt Heaney Apps CodeWithChris ...recommend that your launch screen looks as similar to your first scene as possible so that if the launch screen appears for a really short amount of time, like 0.25 of a second, the user doesn't get an ugly view/edit/jump. Once again, I am new to this as well, so keep that in mind.
Jul ’20
Reply to Unable to initialized a class that subclasses SKShapeNode, specifically (rectOf: CGSize)
Well below is as close as I could get to your code. It compiles, but at runtime I get an Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value error, which I assume is because the object never gets created. Thanks for your reply and I promise to start reading that section, but with me being new at Swift, it might take me a while. So any obvious errors you could point out would be greatly apperciated. Thanks again /*  GameScene.swift/ import SpriteKit import GameplayKit class GameScene: SKScene, SKPhysicsContactDelegate {     var pegBaseBoard : PegBaseBoard?     override func didMove(to view: SKView) {     let background = SKSpriteNode(imageNamed: "background") background.size = self.size     background.position = CGPoint(x: self.size.width/2, y: self.size.height/2)     background.zPosition = -1     self.addChild(background)     pegBaseBoard! = PegBaseBoard.init(rectOfPegBase : CGSize(width: self.size.width * 0.8, height: self.size.height * 0.2))     self.addChild(pegBaseBoard!)     } } /* //  PegBaseBoard.swift/ import Foundation import SpriteKit class PegBaseBoard : SKShapeNode {         convenience init(rectOfPegBase size: CGSize) {         self.init(rectOf: size)         self.fillColor = SKColor.red         self.strokeColor = SKColor.red         self.position = .zero }     override init() {         super.init()     }     required init?(coder aDecoder: NSCoder) {    fatalError("init(coder:) has not been implemented")     } }
Jul ’20
Reply to Unable to initialized a class that subclasses SKShapeNode, specifically (rectOf: CGSize)
Ok, the code below works, as I can tell because the pegBaseBoard is filled with red. So if I consider this step one, how do I start passing extra parameters so I can set the fill, and other properties in the subClass file? import Foundation import SpriteKit class PegBaseBoard : SKShapeNode {     override init() {         super.init()     }     required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented")     } } import SpriteKit import GameplayKit class GameScene: SKScene, SKPhysicsContactDelegate { var pegBaseBoard = PegBaseBoard()     override func didMove(to view: SKView) { let background = SKSpriteNode(imageNamed: "background") background.size = self.size background.position = CGPoint(x: self.size.width/2, y: self.size.height/2) background.zPosition = -1 self.addChild(background) pegBaseBoard = PegBaseBoard.init(rectOf : CGSize(width: self.size.width * 0.8, height: self.size.height * 0.2)) pegBaseBoard.fillColor = SKColor.red self.addChild(pegBaseBoard)   } }
Jul ’20
Reply to How to use CGSize or CGpoint as values in a method parameter
After the code in the OP, where my subclassed SKShapeNode is created, I want to call a method that would do everything (color, zPos, shape relative to screen back, etc.). A method that looks like this: pegBaseBoard.setupPBB(bColor: SKColor.red, bStroke: SKColor.red, backScreenSize: background.position, zPos: 0, dir: direction, rectOf : CGSize(width: background.size.width * 0.8, height: background.size.height * 0.2)) It's that last parameter I can't seem to declare, or call, correctly. I've been sitting in the Playground non-stop and I just can't figure out the proper syntax.
Jul ’20
Reply to How to use CGSize or CGpoint as values in a method parameter
Showing code from playground, not my actual code So yes, I can declare a func/method like this: func moveNode(theNode : SKShapeNode, myRect : CGSize){ print ("hello") } This returns no errors. However when I try to call the func/method like this: moveNode(theNode: sNode, myRect: CGRect) I get the following error: Cannot convert value of type 'CGRect.Type' to expected argument type 'CGSize' Now I realize I am passing in a function, and it returns a struct. I just cannot figure out how to use it in the func/method call
Jul ’20
Reply to How to use CGSize or CGpoint as values in a method parameter
I sincerely don't know what to say. I tried moveNode(theNode: sNode, myRect: CGSize(width: background.size.width * 0.8, height: background.size.height * 0.2)) not this line exactly, but this syntax, many times in the beginning, so many ways. And I kept getting an error similar to Cannot convert type CGRect. Over and over, I tried changing so many things and it would not work. I'm new to Swift, and haven't programmed in over a decade, but I'm not an *****. So know when I tried it again, as you suggested. It works. I just don't know what happened, or how to say sorry for wasting everyone's time. Thanks
Jul ’20
Reply to Unable to update a passed struct, even tho it's declared as var
Thank you, so we're talking reference pointers here (finally something I recognize), and yes, my code gets sloppier the more walls I hit. I barely transitioned from C to an Objective language, and at my age I wonder if I am capable of learning anything new. Thanks again Although as a side note, when I watched it change to 0.1 in the debugger, it actually changed to: 0.10000000000000001 What's up with that?
Jul ’20
Reply to Having more than one init in a subclass of SKShapeNode
At the bottom is: my GameViewController my GameScene and my subclassing of the SKShapeNode (there's some duplication I need to clean ups, but the code works I initiate a new instance of the subclass pegPlaceHolder = PlaceHolderRect(rectOf: CGSize(width: self.size.width * 0.7, height: self.size.height * 0.2 )) The init my subclass calls is this one from the documentation: _init(rectOf: CGSize) Then I do other things such as colors, positioning, etc. What I would like to do, is my initialization of the subclass instance with more parameters. And with that one call send more parameters and have my subclass do the initial standard init, followed by another init with the addition parameters. This is what I cannot figure out how to do. p.s. If you know of a way to copy Xcode into this forum, in proper formatting it would make it so much easier. I spend twice the time on here deleting the extra newlines, after the pasting the code here, then asking questions The code is in the next reply as this post exceeds the limit
Jul ’20
Reply to Having more than one init in a subclass of SKShapeNode
GameViewController import UIKit import SpriteKit import GameplayKit class GameViewController: UIViewController {     override func viewDidLoad() {         super.viewDidLoad()         if let view = self.view as! SKView?         {             // Build SKScene from background image             let scene = GameScene(size: CGSize(width: 1536, height: 2048))             // Set the scale mode to scale to fit the window             scene.scaleMode = .aspectFit             // Present the scene             view.presentScene(scene)             //change when done             view.ignoresSiblingOrder = true             view.showsFPS = true             view.showsNodeCount = true         }     }     override var shouldAutorotate: Bool {         return true     }     override var supportedInterfaceOrientations: UIInterfaceOrientationMask {         if UIDevice.current.userInterfaceIdiom == .phone {             return .allButUpsideDown         } else {             return .all         }     }     override var prefersStatusBarHidden: Bool {         return true     } } GameScene import SpriteKit import GameplayKit class GameScene: SKScene, SKPhysicsContactDelegate {     var pegBase = pegBaseBoard()     var pegPlaceHolder = PlaceHolderRect()     class UISwipeGestureRecognizer : UIGestureRecognizer{     }   override func didMove(to view: SKView)     {         let backGround = SKSpriteNode(imageNamed: "background")         backGround.size = self.size         backGround.position = CGPoint(x: self.size.width/2, y: self.size.height/2)         backGround.zPosition = -1         self.addChild(backGround)         pegPlaceHolder = PlaceHolderRect(rectOf: CGSize(width: self.size.width * 0.7, height: self.size.height * 0.2 ))         pegPlaceHolder.setDims(w: self.size.width * 0.7, h: self.size.height * 0.2)         pegPlaceHolder.strokeColor = .green         pegPlaceHolder.fillColor = .green         pegPlaceHolder.zPosition = 0         pegPlaceHolder.setFlush(dirFlush: .lefthanded, parent: backGround)         self.addChild(pegPlaceHolder)     } } PegBaseHolder subclass of SKShapeNode import Foundation import SpriteKit import GameplayKit class PlaceHolderRect : SKShapeNode {     var height: CGFloat = 0.0     var width:  CGFloat = 0.0     override init() {         super.init()         self.isHidden = true         self.strokeColor = SKColor.green         self.fillColor = SKColor.green         self.zPosition = 0     }     required init?(coder aDecoder: NSCoder) {         fatalError("init(coder:) has not been implemented")     }     func setDims(w: CGFloat, h: CGFloat){         width = w         height = h     }     func setFlush (dirFlush: directionToFlush, parent: SKSpriteNode){         var finalX: CGFloat         let rectOf: CGRect = parent.calculateAccumulatedFrame()         ///calculate modifier of x         ///let modifier = difference between width of parent and width of child and divide it in half         let xBase = (rectOf.size.width - self.width)/2         switch dirFlush         {             case .lefthanded:             finalX = (rectOf.size.width / 2) - xBase             case .righthanded:             finalX = (rectOf.size.width / 2) + xBase         case .center:             finalX = (rectOf.size.width / 2)     }         self.position = CGPoint(x: finalX, y: self.height/2)         self.isHidden = false     } }
Jul ’20