Yes, very new to Swift. Within a GameScene I'm creating a background and then an SKShapeNode within it.
Everything works.
So now I have a subclass of the SKShapeNode, and it works for initing the SKShapeNode. So my next my goal is to add a method to position, take care of color, etc.
But I just can't figure out how to pass certain items within methods/functions.
For instance this is the code I use within GameScene, that works:
I just can't seem to figure out how to pass the background.size property. Yes, I could break it down to width and height separately and then pass them to my method, but that sounds kludgy.
Would like to do it correctly.
Thank you
Everything works.
So now I have a subclass of the SKShapeNode, and it works for initing the SKShapeNode. So my next my goal is to add a method to position, take care of color, etc.
But I just can't figure out how to pass certain items within methods/functions.
For instance this is the code I use within GameScene, that works:
Code Block 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) pegBase = SKShapeNode(rectOf: CGSize(width: self.size.width * 0.8, height: self.size.height * 0.2))
I just can't seem to figure out how to pass the background.size property. Yes, I could break it down to width and height separately and then pass them to my method, but that sounds kludgy.
Would like to do it correctly.
Thank you