Search code examples
iosswiftuiviewcontrollertouchesbegan

Touchesbegan method inactive from viewcontroller


When I am adding a UIImageview from the viewcontroller, I want to make the touchesbeganmethod inactive till the uiimage is pressed.

Now I already have everything set up, I just need to know how I can prevent the gamescene from noticing touches by setting up code (only) in the viewcontroller.

Anyone knows how?

GameScene.paused = true // this pauses the game, but the touchesbegan method is still active!

Solution

  • You could set userInteractionEnabled to false on the view you want to disable the touches or you could do the check on the begining in touches began like this:

    if GameScene.paused == true {
        return
    }