-2

I have this function in gamescene.swift:

func pauseGame() {

    scene!.view!.paused = true
    println("pause")
    updateScoreTimer.invalidate()

}

Now I want to call it from the AppDelegate.swift but I don't know what to insert into "<#GameScene#>"

GameScene.pauseGame(<#GameScene#>)

Tower
  • 88
  • 7
  • What is the parameter for? – Vasil Garov May 14 '15 at 14:33
  • That's the thing: I need to insert a parameter but the function has no. And when I delete the parameter there is an error: "missing argument for parameter #1 in call" – Tower May 14 '15 at 14:34
  • You're trying to call an instance method but you're prefixing the call with the class name (like you're calling a class method). You need an instance of `GameScene` to call your `pauseGame` method. – ABakerSmith May 14 '15 at 15:01

1 Answers1

0

Well if your AppDelegate.swift instantiates the scene, you would call the method on the scene instance from app delegate. However I don't see why you would want to pause the game from appDelegate. Are you wanting to call this when the app launches?

CodyMace
  • 646
  • 1
  • 8
  • 19
  • I want to call this function when the app will enter the background or it will resign active. – Tower May 14 '15 at 16:57
  • I thought that might be what you want. But doesn't leaving the scene pause when you put the app in the background anyway? – CodyMace May 14 '15 at 17:00
  • 1
    This might solve part of your problem: http://stackoverflow.com/questions/19014012/sprite-kit-the-right-way-to-multitask – CodyMace May 14 '15 at 17:01
  • So maybe what you want to do is hold on to an instance of your scene in appDelegate, and then in applicationWillResignActive call your method on the instance of the scene. – CodyMace May 14 '15 at 17:03