title: Smooth switching between texture atlas animations
body: <p><strong>How can I make smooth transitions between multiple animations on the same character without delay?</strong></p>
  
  <p>I'm developing a game in iOS Swift with a jumping character. This character has a few animations, like the basic animation, the jump animation and a landing animation. </p>
  
  <p>I set the texture atlas for every animation as follows:</p>
  
  <pre><code>    // Basic
      let surferBasicAnimatedAtlas = SKTextureAtlas(named: "surfer_basic.atlas")
  
      let numImages = surferBasicAnimatedAtlas.textureNames.count
  
      for var i=0; i&lt;numImages; i++ {
          let surferBasicTextureName = "surfer_basic_000\(i)"
          self.surferBasicFrames.append(surferBasicAnimatedAtlas.textureNamed(surferBasicTextureName))
      }
  
      // Jump
      let surferJumpAnimatedAtlas = SKTextureAtlas(named: "surfer_jump.atlas")
  
      let numJumpImages = surferJumpAnimatedAtlas.textureNames.count
  
      for var i=0; i&lt;numJumpImages; i++ {
          let surferJumpTextureName = "surfer_jump_000\(i)"
          self.surferJumpFrames.append(surferJumpAnimatedAtlas.textureNamed(surferJumpTextureName))
      }
  
      // Landing
      let surferLandingAnimatedAtlas = SKTextureAtlas(named: "surfer_landing.atlas")
  
      let numLandingImages = surferLandingAnimatedAtlas.textureNames.count
  
      for var i=12; i&lt;numLandingImages; i++ {
          let surferLandingTextureName = "surfer_landing_000\(i)"
          self.surferLandingFrames.append(surferLandingAnimatedAtlas.textureNamed(surferLandingTextureName))
      }
  
      // Pick textures
      self.surferWalkingFrames = surferBasicFrames
  
      let firstFrame = surferWalkingFrames[0]
      self.character = SKSpriteNode(texture: firstFrame)
  
      self.character.runAction(SKAction.repeatActionForever(SKAction.animateWithTextures(surferWalkingFrames, timePerFrame: (1 / 30), resize: false, restore: true)), withKey:"surferBasic")
  </code></pre>
  
  <p>When I touch the screen the basic animation should stop and the jump animation should run, but it causes a delay. About one second after the touch the jump animation starts. </p>
  
  <p>I've tried this:</p>
  
  <pre><code>override func touchesBegan(touches: Set&lt;NSObject&gt;, withEvent event: UIEvent) {
  
      self.character.removeActionForKey("surferBasic")
  
      self.surferWalkingFrames = surferJumpFrames
      self.character.runAction(SKAction.repeatActionForever(SKAction.animateWithTextures(surferWalkingFrames, timePerFrame: (1 / 30), resize: false, restore: true)), withKey:"surferJump")
  }
  </code></pre>
  
  <p><strong>How can I make smooth transitions between multiple animations on the same character without delay?</strong></p>