ios - Inappropriate Expected declaration error -


why getting error in code, seems normal me. declare 'hills' variable still getting error "expected declaration" both 'hills' , '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) 

i suspect reason expected declaration message have placed code inside of class without putting inside of method. example below compiles, gives same error seeing if not included inside of setup method:

class mynode: skspritenode {     func setup() {         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)     } } 

Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -