iphone - Running a function when the game becomes active iOS - SpriteKit -


in game in swift / spritekit, have problem when user quits app , opens again. if game on pause menu , paused, when game reloaded game unpaused labels on pause menu not disappear. how keep game paused when reopen it? have tried

    func applicationwillenterforeground(application: uiapplication) {     // called part of transition background inactive state; here can undo many of changes made on entering background.     let scene = gamescene(size: cgsize(width: 2048, height: 1356))     scene.view?.paused = true } 

but not doing anything. have tried pause() messes things up. appreciated.

you want use applicationwillresignactive function pause scene, doing scene.speed = 0 pause scene (don't know why, doesn't quite work using pause). here can display pause menus (which appear doing).

then want use applicationdidbecomeactive function continue game. here checks see if (guessing here) "resume" button pressed, , in response method that, set scene.speed = 1. here response method, requires starting (animations, actions, hiding pause menu(s), or music).

i say, these 2 functions use, free use whichever 2 functions have on/off kind of thing. i've found these reliable.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -