简体   繁体   English

ViewesController中的Touchesbegan方法未激活

[英]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. 当我从视图控制器添加UIImageview时,我想使touchesbeganmethod处于不活动状态,直到按下uiimage为止。

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. 现在我已经完成了所有设置,我只需要知道如何通过在viewcontroller中设置代码(仅)来防止游戏场景注意到触摸。

Anyone knows how? 有人知道吗?

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

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: 您可以在要禁用触摸的视图上将userInteractionEnabled设置为false,或者可以像这样对开始的触摸进行检查:

if GameScene.paused == true {
    return
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM