Hi everyone. I've been trying to convert a script I wrote in Lua to Swift, but it's been a pain since I'm having a lot of problems I can't find the solution to, mainly because I only started learning Swift yesterday.
The problem I have at the moment is with the following:
// There's more code above here but it works fine
var VIEW:SKView! // Because I have no clue how to get the view otherwise
func GENERATE(SCENE:SKScene) { // Function works
//Contents of function don't matter, but the SKScene is needed
}
class GameScene: SKScene {
// The sequence below is used later by a SKSpriteNode (node.runAction(SEQ))
let SEQ = SKAction.sequence([SKAction.scaleTo(0,duration:0.2),SKAction.removeFromParent(),SKAction.runBlock({
VIEW.backgroundColor = UIColor.blueColor()
GENERATE(self) // I need the GameScene but it won't let me use it no matter what I try
})])
override func didMoveToView(view: SKView) {
VIEW = view // I don't really like doing this but it seems to be the only way
GENERATE(self) // This works fine
}
// There's more code down here but it works fineAs you can see, I've tried a bit of dodgy stuff to get it to work, but it doesn't. Anyone know how to get this working?