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:
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 }
Oct ’21
Reply to How to refine the shape of an SKSpriteNode for tap gestures?
Hence, it will not react to tap outside the shape. While SKPhysicsBody(texture: sprite.texture!, CGSize) does create the physics shape, UITapGestureRecognizer is not affected by it. It sees the tap in the rectangle/square area. Nevertheless, I find that for simple shape as diamond, the test I proposed is really simple. But what happens when I am doing a more complex SKSpriteNode? Is this the way Swift handles this?
Jul ’21
Reply to How can I access an array in one of my classes?
I cannot access the screenshot. I wish I knew what was up with my server, sorry myGV is a structure to hold a few global variables. myGV.guessBar = GuessBar : SKSpriteNode The GuessBar has 6 children, GuessSlot : SKSpriteNode. GuessBar has an array that has all six instances of them. Here is the code for GuessBar: class GuessBar : SKSpriteNode{     var guessSlots : [GuessSlot] = []     init(color: SKColor, size: CGSize) {        super.init(texture: nil, color: color, size: size)     }     required init?(coder aDecoder: NSCoder) {         fatalError("init(coder:) has not been implemented")     }  } Here is the code where I fill the arrays in the guessBar func createGuessBar(color: SKColor, size: CGSize, factor: Int) -> GuessBar {     let myGuessBar = GuessBar(color : color, size: size) //other unrelated code     for x in 0...5{         let mGuessSlot = GuessSlot(color: .clear, size: CGSize(width: iFactor, height: rFactor), width: myGuessBar.size.width,  iFactor: x, guessBarRef: myGuessBar)         myGuessBar.guessSlots.append(mGuessSlot)     } //other unrelated code     return myGuessBar } So the exact info from the debugger reads: myGV.guessBar = (SKSpriteNode?) 0x0000600001984580 *SpriteKit.SKSpriteNode (SKSpriteNode) *guessSlots ([GuessAgain.GuessSlot]) 6 values myGV.guessBar.guessSlots = Invalid Expression The way I see it, everything is running fine. If I expand the guessSlots in the debugger it lists each value. I just can't get the syntax right, going by the last line in the debugger, to access that array from my main structure myGV.
May ’21
Reply to Having strange trouble with touchesMoved, need help.
I got the answer over at Stack overflow, https://stackoverflow.com/questions/67511055/having-a-strange-trouble-with-touchesmoved-position-doesnt-match-location-wher?noredirect=1#comment119406263_67511055 Someone took the time to recreate my issue and had me change: let touchLocation = touch.location(in: self)  to let touchLocation = touch.location(in: gemBase) Of course that leads me to another question, but I'll start another thread for that.
May ’21
Reply to Having strange trouble with touchesMoved, need help.
In which class is this ? ie, what is self ? GameScene toggleHigh, line 10, isMoving That's misc, and a copy error. All the other code be removed and it's the same thing what is the result of the print ? Is it what you expect ? No it's not, that's the problem. So if I move the gemBase, which is its own class) to the right by let's say 100. Then the print result is 100 more than where I'm touching on the screen. That's why I wondered this is due to the gem being owned by the gemBase.
May ’21
Reply to Having strange trouble with touchesMoved, need help.
I cannot access the URL, (after removing the spaces) All of a sudden FileZilla won't properly transfer images at all (yes, set to binary). Looking for a new FTP. Have added super. to all my touches (as seen below) and it still happens     override func touchesMoved(_ touches: SetUITouch, with event: UIEvent?){         super.touchesMoved(touches , with:event)         guard touches.first != nil else { return }         if toggleHigh {highliteGem(theGem: myGems[0], clearAll: true)}         if let touch = touches.first, let node = myGV.currentGem, node.isMoving == true {             let touchLocation = touch.location(in: self)             node.moved    = true             print(touchLocation)             node.position = touchLocation             node.isMoving = true             node.inSlot = false             //addTrailToTwinkle(theNode: node)         }     }
May ’21