Why am I getting an error in this code, it seems perfectly normal to me. I declare 'hills' as a variable but I am still getting the error "Expected declaration" for both 'hills' and 'bg'.
var bg = SKSpriteNode(imageNamed: "sky")
bg.position = CGPointMake(bg.size.width / 2, bg.size.height / 2)
self.addChild(bg)
var hills = SKSpriteNode(imageNamed: "hills")
hills.position = CGPointMake(hills.size.width / 2, 300)
self.addChild(hills)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…