Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS

IOS SPRITEKIT

I have this code for a game I am learning how to make:

import SpriteKit
class GameScene: SKScene {
    override func didMoveToView(view: SKView) {
    backgroundColor = SKColor.whiteColor()
    let background = SKSpriteNode(imageNamed: "background1")
    background.position = CGPoint(x: size.width/2, y: size.height/2)
    background.anchorPoint = CGPoint(x: 0.5, y: 0.5) // default
    // background.zRotation = CGFloat(M_PI) / 8
    background.zPosition = -1
    addChild(background)

    let zombie = SKSpriteNode(imageNamed: "zombie1")
    zombie.position = CGPoint(x: 400, y: 400)
    addChild(zombie)
    }
    override func update(currentTime: NSTimeInterval) {
        zombie.position = CGPoint(x: zombie.position.x + 4,
        y: zombie.position.y)
    }
}

When I put in the override func update in, i get an error at the line where I use the zombie.position. The error says: "use of unresolved indentifier 'zombie'. Why does it do this?

Thanks.