Refer to object in another class
<p>I simply want to code in 'didSimulatePhysics()' to get the shark to go in the opposite direction when it reaches the end of the screen. But I can not get Swift to find the shark when I try to use it in the 'didSimulatePhysics()'</p>

<p><strong>GameElementsClass:</strong></p>

<pre><code>import SpriteKit

 extension GameScene {

    func createSharkAtPosition (position:CGPoint, ofType type:SharkType) -&gt; SharkNode {

        let node = SharkNode()
        let position = CGPoint(x: position.x * scaleFactor, y: position.y)
        node.position = position
        node.name = "SHARKNODE"
        node.sharkType = type
        var sprite:SKSpriteNode


        sprite = SKSpriteNode(imageNamed: "shark1")

        node.addChild(sprite)

        node.physicsBody = SKPhysicsBody(rectangleOfSize: sprite.size)
        node.physicsBody?.dynamic = true
        node.physicsBody?.affectedByGravity = false
        node.physicsBody?.velocity.dx = CGFloat(-60)

        node.physicsBody?.categoryBitMask = CollisionBitMask.Shark
        node.physicsBody?.collisionBitMask = 0


        return node
    }
}
</code></pre>

<p><strong>GameSceneClass:</strong></p>

<pre><code>func sharkMaker() {
    let randomXPos = arc4random_uniform(170) + 10
    let yPosition = CGRectGetMidY(self.frame) + 200 * CGFloat(counter)
    counter += 1
    let shark = createSharkAtPosition(CGPoint(x: CGFloat(randomXPos), y:    yPosition - 180), ofType: SharkType.normalShark)
    foreground.addChild(shark)

}


 override func didSimulatePhysics() {

    if node.position.x &lt; -10 {
        node.xScale =  -1
        node.physicsBody?.velocity.dx = CGFloat(50)
    }else if (node.position.x &gt; self.size.width + 10) {
        node.xScale = 1
        node.physicsBody?.velocity.dx = CGFloat(-50)
    }
</code></pre>