Post

Replies

Boosts

Views

Activity

Reply to How can I pass a function pointer in Swift?
Thanks for the answer, I will have to study up on Selectors, hate all this different terminology. For instance the syntax: action: action, for: .touchUpInside makes no sense to me. To me, it's still a call back. Will still have to find out how to pass a pointer to a function at some point I guess. Will mark you answer correct, just want to make sure you see this comment p.s. Also confused since the sample code that worked, without having the second action with the comma:
Topic: UI Frameworks SubTopic: UIKit Tags:
Oct ’21
Reply to What are the SKPhysics settings to make a ball bounce?
How did you define pathToDraw ? I ran the code below four times, once for each edge. func makeLine (pA: CGPoint, pB: CGPoint) -> SKShapeNode { let yourLine = SKShapeNode() let pathToDraw = CGMutablePath() pathToDraw.move(to: pA) pathToDraw.addLine(to: pB) yourLine.lineWidth = 5 yourLine.path = pathToDraw yourLine.isUserInteractionEnabled = false yourLine.strokeColor = .clear yourLine.isHidden = false yourLine.zPosition = 1 yourLine.physicsBody = SKPhysicsBody(edgeLoopFrom: pathToDraw) yourLine.physicsBody?.affectedByGravity = false yourLine.physicsBody?.isDynamic = false yourLine.physicsBody?.pinned = true yourLine.physicsBody?.categoryBitMask = bodyMasks.edgeMask.rawValue yourLine.physicsBody?.collisionBitMask = bodyMasks.ballMask.rawValue yourLine.physicsBody?.contactTestBitMask = bodyMasks.blankMask.rawValue return yourLine }
Topic: Programming Languages SubTopic: Swift Tags:
Oct ’21
Reply to Is Multiple inheritance not allowed in Swift?
Doh! Thanks. Am going to blame the laziness of autocomplete. That’s why I like to type everything. Ingrains it better.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to How can I use a custom image for a Swift button but still control the text separately?
It works now with me only setting the background image. But can I leave setIamge blank? Or do I have to set it to nil?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to How can I use a custom image for a Swift button but still control the text separately?
So I modified the code as such: //    button.setImage(scaledImage, for: .normal)     button.setBackgroundImage(scaledImage, for: .normal) And that does work. But am unsure if I have to do anything with the .setImage method
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to How can I pass a function pointer in Swift?
Thanks for the answer, I will have to study up on Selectors, hate all this different terminology. For instance the syntax: action: action, for: .touchUpInside makes no sense to me. To me, it's still a call back. Will still have to find out how to pass a pointer to a function at some point I guess. Will mark you answer correct, just want to make sure you see this comment p.s. Also confused since the sample code that worked, without having the second action with the comma:
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to What are the SKPhysics settings to make a ball bounce?
So to make sure I understand...from your posts and my playing around with the code, it doesn't matter where the higher restitution is? i.e. ball, edge, block And their restitutions doesn't combine, the software just used the higher one? i.e. ball.restitution = 0.8 block.restitution = 0.4 restitution used by physics engine will be 0.8
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to What are the SKPhysics settings to make a ball bounce?
How did you define pathToDraw ? I ran the code below four times, once for each edge. func makeLine (pA: CGPoint, pB: CGPoint) -> SKShapeNode { let yourLine = SKShapeNode() let pathToDraw = CGMutablePath() pathToDraw.move(to: pA) pathToDraw.addLine(to: pB) yourLine.lineWidth = 5 yourLine.path = pathToDraw yourLine.isUserInteractionEnabled = false yourLine.strokeColor = .clear yourLine.isHidden = false yourLine.zPosition = 1 yourLine.physicsBody = SKPhysicsBody(edgeLoopFrom: pathToDraw) yourLine.physicsBody?.affectedByGravity = false yourLine.physicsBody?.isDynamic = false yourLine.physicsBody?.pinned = true yourLine.physicsBody?.categoryBitMask = bodyMasks.edgeMask.rawValue yourLine.physicsBody?.collisionBitMask = bodyMasks.ballMask.rawValue yourLine.physicsBody?.contactTestBitMask = bodyMasks.blankMask.rawValue return yourLine }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to What are the SKPhysics settings to make a ball bounce?
It turns out that swapping out yourLine.physicsBody = SKPhysicsBody(edgeLoopFrom: pathToDraw) for yourLine.physicsBody = SKPhysicsBody(edgeChainFrom" pathToDraw) made it work Not sure why though.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’21