# I am stuck, I need help

**URL:** <https://forums.kodeco.com/t/i-am-stuck-i-need-help/24463>\
**Category:** 2D iOS & tvOS Games by Tutorials\
**Created:** [December 24, 2016, 5:53pm UTC](https://forums.kodeco.com/t/i-am-stuck-i-need-help/24463 "2016-12-24T17:53:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![abd1kadir](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@abd1kadir](https://forums.kodeco.com/u/abd1kadir)\
**Post date:** [December 24, 2016, 5:53pm UTC](https://forums.kodeco.com/t/i-am-stuck-i-need-help/24463/1 "2016-12-24T17:53:15Z")

</div>

I am making the zombie conga game in the book but I can’t move the zombie,. It keeps showing errors. The last three lines keeps showing errors in xcode, it is saying use of unresolved identifier ‘zombie’, and also override func can only be specified on class members.

import SpriteKit

class GameScene: SKScene {

```
let zombie = SKSpriteNode(imageNamed: "zombie1")

override func didMove(to view: SKView) {
    backgroundColor = SKColor.black
    let background = SKSpriteNode(imageNamed: "background1")
    background.anchorPoint = CGPoint(x: 0.5, y: 0.5)
    background.position = CGPoint(x: size.width/2, y: size.height/2)
   
    background.zPosition = -1
    addChild(background)
    
    let mySize = background.size
    print("Size: \(mySize)")
    
    zombie.position = CGPoint(x: 400, y: 400)
    //zombie.setScale(2)
    addChild(zombie)
}

```

}

override func update(\_currentTime: TimeInterval) {  
zombie.position = CGPoint(x: zombie.position.x + 8,  
y: zombie.position.y)  
}

---

<div class="post-metadata">

**Author:** ![fusetech](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/fusetech/32/97552_2.png) [@fusetech](https://forums.kodeco.com/u/fusetech)\
**Post date:** [December 25, 2016, 6:50am UTC](https://forums.kodeco.com/t/i-am-stuck-i-need-help/24463/2 "2016-12-25T06:50:46Z")

</div>

Assuming what you have posted is exactly what your class currently looks like, you need to check your curly braces.

Currently your update function is being declared outside of the GameScene class. It therefore doesn’t know about zombie or how to override update.

---

<div class="post-metadata">

**Author:** ![muzafar](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/muzafar/32/59239_2.png) [@muzafar](https://forums.kodeco.com/u/muzafar)\
**Post date:** [March 5, 2017, 1:53pm UTC](https://forums.kodeco.com/t/i-am-stuck-i-need-help/24463/3 "2017-03-05T13:53:37Z")

</div>

hey fusetech

I have the same issue as OP.

when i declare the update function inside the GameScene class it gives me the error ‘use of unresolved identifier’ zombie’ ’

how do i fix this ?

below is all my code

* * *

import SpriteKit

class GameScene: SKScene {  
override func didMove(to view: SKView) {  
backgroundColor = SKColor.black //set background colour to black  
let background = SKSpriteNode(imageNamed: “background1”) // created sprite (background) (I)  
// background.position = CGPoint(x: size.width/2, y: size.height/2) //set the position to center of scene  
background.anchorPoint = CGPoint(x: 0.5, y: 0.5) // setting the anchor point for background  
background.position = CGPoint(x: size.width/2, y: size.height/2) // positioning the sprite(background) (II)  
// background.zRotation = CGFloat(M\_PI) / 8 // rotating background(sprite). this will happen around the anchor point  
background.zPosition = -1 // setting the prites(background) z position. only really necessary for the background, to ensure the background is the first thing to be drawn on the screen. (III)  
addChild(background) // adding the sprite(background) to the scene.(IV)  
let mySize = background.size // this and line below are to determine size of the sprite in output box below  
print(“size: (mySize)”)

```
    let zombie = SKSpriteNode(imageNamed: "zombie1")//Created Sprite (Zombie)
    zombie.position = CGPoint(x: 400, y: 400) // Positioned Sprite (Zombie)
    // zombie.xScale = CGFloat(2) // scaled x axis 2 times
    // zombie.yScale = CGFloat(2) // scaled y axis 2 times
    addChild(zombie)
    
    let mySizeZombie = zombie.size
    print ("zombie size: \(mySizeZombie)")

    }
override func update(_ currentTime: TimeInterval) {
    zombie.position = CGPoint (x: zombie.position.x + 8,
                               y: zombie.position.y)
}

```

## }

---

<div class="post-metadata">

**Author:** ![fusetech](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/fusetech/32/97552_2.png) [@fusetech](https://forums.kodeco.com/u/fusetech)\
**Post date:** [March 5, 2017, 6:07pm UTC](https://forums.kodeco.com/t/i-am-stuck-i-need-help/24463/4 "2017-03-05T18:07:22Z")

</div>

@muzafar It looks like you are missing the instance variable for zombie on the GameScene class.

Here is an updated copy of your source, but I would advise to double check the source from the book to understand what was missing/why it was broken.

`
import SpriteKit
class GameScene: SKScene {
	var zombie: SKSpriteNode! //This line was missing
	override func didMove(to view: SKView) {
		backgroundColor = SKColor.black //set background colour to black
		let background = SKSpriteNode(imageNamed: "background1") // created sprite (background) (I)
		// background.position = CGPoint(x: size.width/2, y: size.height/2) //set the position to center of scene
		background.anchorPoint = CGPoint(x: 0.5, y: 0.5) // setting the anchor point for background
		background.position = CGPoint(x: size.width/2, y: size.height/2) // positioning the sprite(background) (II)
		// background.zRotation = CGFloat(M_PI) / 8 // rotating background(sprite). this will happen around the anchor point
		background.zPosition = -1 // setting the prites(background) z position. only really necessary for the background, to ensure the background is the first thing to be drawn on the screen. (III)
		addChild(background) // adding the sprite(background) to the scene.(IV)
		let mySize = background.size // this and line below are to determine size of the sprite in output box below
		print("size: (mySize)")
		let zombie = SKSpriteNode(imageNamed: "zombie1")//Created Sprite (Zombie)
		zombie.position = CGPoint(x: 400, y: 400) // Positioned Sprite (Zombie)
		// zombie.xScale = CGFloat(2) // scaled x axis 2 times
		// zombie.yScale = CGFloat(2) // scaled y axis 2 times
		addChild(zombie)
                self.zombie = zombie //This line was missing
		let mySizeZombie = zombie.size
		print ("zombie size: \(mySizeZombie)")	
	}
	override func update(_ currentTime: TimeInterval) {
		zombie.position = CGPoint (x: zombie.position.x + 8,
	                           y: zombie.position.y)
	}
}
`

Good luck

---

<div class="post-metadata">

**Author:** ![muzafar](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/muzafar/32/59239_2.png) [@muzafar](https://forums.kodeco.com/u/muzafar)\
**Post date:** [March 5, 2017, 7:09pm UTC](https://forums.kodeco.com/t/i-am-stuck-i-need-help/24463/5 "2017-03-05T19:09:15Z")

</div>

@fusetech

thanks this solved my problem.

As i understand it I had defined zombie within DidMove(to\_🙂 and not within the class GameScene.

so the update(\_🙂 function didnt know what zombie was.  
This could be made clearer in the book, but I guess it is an intermediate level which i may not be at.

Thanks again.

---

<div class="post-metadata">

**Author:** ![pentae](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/pentae/32/69770_2.png) [@pentae](https://forums.kodeco.com/u/pentae)\
**Post date:** [July 26, 2017, 10:22am UTC](https://forums.kodeco.com/t/i-am-stuck-i-need-help/24463/6 "2017-07-26T10:22:30Z")

</div>

Thank you - I just bought the book and was stuck on this section also. I don’t know if its because i’m using a newer version of Xcode but as a noob this almost derailed me. 🙂 Perhaps the authors could check if it needs updating in this section so new buyers don’t also get stuck
