My "addChild" is not working Swift -
My "addChild" is not working Swift -
i have annoying error when create add together kid statement says (as error): "expected declaration" on line of addchild statement using xcode 6 latest version of swift
here code:
// // gamescene.swift // pocket rocket // // created lucas farleigh on 11/11/2014. // copyright (c) 2014 lucas farleigh. rights reserved. // import spritekit; class gamescene: skscene { allow background = skspritenode(imagenamed:"background") allow playbutton = skspritenode(imagenamed: "playbutton") override func didmovetoview(view: skview) { playbutton.position = cgpointmake(cgrectgetmidx(self.frame), cgrectgetmidx(self.frame)) background.yscale = 2 background.position = cgpointmake(cgrectgetmidx(self.frame), cgrectgetmidx(self.frame)) } self.addchild(background) override func touchesbegan(touches: nsset, withevent event: uievent) { /* called when touch begins */ touch: anyobject in touches { allow location = touch.locationinnode(self) } } override func update(currenttime: cftimeinterval) { /* called before each frame rendered */ } }
looks closed didmovetoview
method before line:
override func didmovetoview(view: skview) { playbutton.position = cgpointmake(cgrectgetmidx(self.frame), cgrectgetmidx(self.frame)) background.yscale = 2 background.position = cgpointmake(cgrectgetmidx(self.frame), cgrectgetmidx(self.frame)) self.addchild(background) }
the error because can't have expressions @ class level.
swift
Comments
Post a Comment