title: Detecting Shake Gesture SpriteKit in Swift
body: <p>I'm trying to detect a shake gesture in an <code>SKScene</code>.This the code I'm using:</p>
  
  <pre><code>import SpriteKit
  import UIKit
  import CoreMotion
  
  class Menu: SKScene {
  
  override func didMove(to view: SKView) {      
  
       self.becomeFirstResponder()
  
       //Game Code
  
  }
  
    override func becomeFirstResponder() -&gt; Bool {
          return true
      }
  
   override func motionEnded(_ motion: UIEventSubtype, with event: UIEvent?) {
          if event?.subtype == UIEventSubtype.motionShake {
              //Run Code
          }
      }
  
      override func willMove(from view: SKView) {
          resignFirstResponder()
      }
  
  
  }
  </code></pre>
  
  <p>But the <code>motionEnded</code> code is not running, it's as if it doesn't detect the shake gesture. This is in an <code>SKScene</code> so I'm not sure if the code differs slightly.</p>
  
  <p>Any help would be greatly appreciated.</p>