ios - Swift SpriteKit Layer/Node doesn't load fast enough -


i created first simple ios game , created layers gamelayer game , pauselayer resume button/node. in gamelayer have button pause game , in pauselayer button/node resume. did in function gets points touchesended function:

    var ispaused = false      func touchend(atpoint pos : cgpoint) {     if ispaused == false && pausebutton.contains(pos) {         pauselayer.ishidden = false         view?.ispaused = true         ispaused = true     }     if ispaused == true && resumebutton.contains(pos) {         pauselayer.ishidden = true         view?.ispaused = false         ispaused = false     }     } 

everything working besides cant see resume button. can click should , game resumes. when delete line view?.ispaused = truethe button displayed should be. gave me idea pausing view might pause process of loading/displaying resume button. how can avoid problem?

well test out theory of not loading quick enough.

you can delay code execution this:

let delayduration:double = 1.0 /* in seconds */   let totaldelaytime = dispatchtime.now() + delayduration   dispatchqueue.main.asyncafter(deadline: totaldelaytime, execute: { view?.ispaused = true }) 

it wait 1 second before evaluating view?.ispaused


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -