Post

Replies

Boosts

Views

Activity

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)         }     }
Topic: Programming Languages SubTopic: Swift Tags:
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.
Topic: Programming Languages SubTopic: Swift Tags:
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.
Topic: Programming Languages SubTopic: Swift Tags:
May ’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.
Topic: Programming Languages SubTopic: Swift Tags:
May ’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?
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’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 How do I allow Xcode to access my local files?
It appears that once I opened my project the long way, File-Open that was it. It took care of everything. Seems like a waste of time.
Replies
Boosts
Views
Activity
May ’21
Reply to Checking what I need to include SQLite in my Swift apps
Nothing. Also,  adding libsqlite3.tbd in the Build Phase is not needed. Every site I visited mentioned the adding that into the Build Phase. So I want to check, is this something that has changed recently with different versions of Xcode?
Replies
Boosts
Views
Activity
May ’21
Reply to Having strange trouble with touchesMoved, need help.
By moving gemBase to the middle, rather than all the way left, the gap between where I touch the screen and how far off to the right the gem is, is less. So is this because the gems are owned by gemBase? If so not sure why this what the solution is
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
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)         }     }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
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.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Having strange trouble with touchesMoved, need help.
I cannot access the URL, (after removing the spaces) Finally got the screenshot up there http:// 98.7.37.117/screen.gif
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
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.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’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.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to How can I access an array in one of my classes?
All my fault. It's right there in the debugger too. My SKSpriteNode should be declared as the subclass, not an SKSpriteNode. That's why I can't access the array. The array exists in my subclass.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jun ’21
Reply to What is the syntax for "if not" in Swift?
Sorry, I wanted the NOT (!) equivalent to : if let twinkling = getHighGem() as? MyGem
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jun ’21
Reply to How to refine the shape of an SKSpriteNode for tap gestures?
ignore the self.isHidden line. I set that to true false later on.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to How to refine the shape of an SKSpriteNode for tap gestures?
Surely it can't view every Node as a rectangle or square? What do you mean ? I mean when you create a spritenode from an image that the node’s area becomes a uniform area that goes beyond the image. ie, look at the orange diamond. Why does the white area (which I drew in for this post) become part of the area the spritenode is part of?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’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?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’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
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