the code that works in Xcode 6 doesn't work with Xcode 7

this is my first question here and apologize for bad English.


I was recently making a game application using Xcode 6.4 which worked perfectly in IOS devices. However, when I upload Xcode 7 Beta 4 to develop my app for IOS 9 there was a problem.

I was using this code in Xcode 6, which was restricting my hero to flip between -1.0 and 1.0 in X-axes, my hero could not flipping to -2.0:


func flip() {
  isUpsideDown = !isUpsideDown

  var scale: CGFloat!
  if isUpsideDown {
  scale = -1.0
  } else {
  scale = 1.0
  }
  let translate = SKAction.moveByX(0, y: scale*(size.height + kMLGroundHeight), duration: 0.1)
  let flip = SKAction.scaleYTo(scale, duration: 0.1)

  runAction(translate)
  runAction(flip)
  }

But now in Xcode 7 this cod seems to not work. Firstly it seems alright but then hero starts to flip to -2.0, -3.0 and this goes on until the hero goes out of frame.

Also this is my game scene cod which worked perfectly on Xcode 6:



override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {

    if isGameOver {
          
            restart()
          
        } else if !isStarted {
          
            start()
          
        } else {
          
            hero.flip()
          
        }
      
    }

I am new to this things and would be appreciated if you answer my question.

Your question is about the SpriteKit framework. Your chances of getting help will be much higher if you move the question to the SpriteKit forum, which is in the Graphics and Games section of the forums.


Additional information that would help someone solve your problem are the values of size.height and kMLGroundHeight. Your translate action moves the hero by the following value:


scale * (size.height + kMLGroundHeight)


The value of scale is either 1 or -1, but if the sum of size.height and kMLGroundHeight is greater than 1, the hero is going to move more than 1 or -1 unit.

the code that works in Xcode 6 doesn't work with Xcode 7
 
 
Q