官术网_书友最值得收藏!

Listening for touches in GameScene

The SKScene class (that GameScene inherits from) includes handy functions that we can use to monitor touch input. Follow these steps to wire up the GameScene class:

  1. In GameScene.swift, in the touchesBegan function, add this code at the very bottom to start the Player flapping when the user touches the screen:
    player.startFlapping() 
  2. After touchesBegan, create two new functions in the GameScene class. These functions stop the flapping when the user lifts his or her finger from the screen, or when an iOS notification interrupts the touch:
            override func touchesEnded(_ touches: Set<UITouch>, 
                with event: UIEvent?) { 
    player.stopFlapping() 
            } 
    
            override func touchesCancelled(_ touches: Set<UITouch>,  
                with event: UIEvent?) { 
    player.stopFlapping() 
            } 
主站蜘蛛池模板: 洛扎县| 西昌市| 襄垣县| 安仁县| 康定县| 信宜市| 汝南县| 临澧县| 南昌县| 敦化市| 大连市| 彭水| 花莲市| 兴业县| 沛县| 秭归县| 毕节市| 武义县| 乌审旗| 肃南| 玛多县| 剑河县| 长乐市| 乌鲁木齐县| 江城| 渝中区| 琼结县| 通河县| 德令哈市| 阜南县| 科技| 宁海县| 舞阳县| 瑞丽市| 永吉县| 电白县| 苍梧县| 隆昌县| 永州市| 济宁市| 永康市|