0

I have two scenes (MainScene and ResultScene). The game starts with the MainScene. The first presentation of MainScene is good, the game runs smoothly, but if the game changes to ResultScene and from ResultScene back to MainScene, my hero sprite is vibrating.

Here's the method from ResultScene:

func presentScene() {
    let scene = MainScene()
    scene.size = self.frame.size
    scene.scaleMode = .AspectFit
    self.view!.ignoresSiblingOrder = true
    self.view!.presentScene(scene)
}

Here's the way how i move the hero:

var velocity: CGFloat = 360
override func update(currentTime: NSTimeInterval) {
    self.myHero?.physicsBody?.velocity.dx = self.velocity
}     

And here's I modify the velocity:

self.increaseVelocityTimer = NSTimer.scheduledTimerWithTimeInterval(17, target: self, selector: Selector("increaseVelocity"), userInfo: nil, repeats: true)

func increaseVelocity() {
   self.velocity += 60
}
mugx
  • 9,869
  • 3
  • 43
  • 55
  • Not enough and the wrong code. Post the code where you change the hero's position or rotation and any variables involved therein. – CodeSmile Jan 09 '15 at 14:04
  • @LearnCocos2D Sorry for late answer. I move the hero in this way: var velocity: CGFloat = 360 override func update(currentTime: NSTimeInterval) { self.myHero.physicsBody?.velocity.dx = self.velocity } – mephisto91 Jan 13 '15 at 18:57
  • and how is velocity modified? please edit your question with the code, don't add it in a comment – CodeSmile Jan 13 '15 at 19:12
  • you should definitely not use nstimer but update or skaction to increase velocity, see http://stackoverflow.com/questions/23978209/spritekit-creating-a-timer – CodeSmile Jan 14 '15 at 07:27
  • The vibration is fully independent how i modify the velocity, because if i turn off the timer, the vibration is still there. Immediately begins when the MainScene is presenteted secondly. @LearnCocos2D – mephisto91 Jan 14 '15 at 10:04
  • Does your game also get slower? Like lag – Cing Mar 18 '16 at 23:47

0 Answers0