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

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() 
            } 
主站蜘蛛池模板: 巴林右旗| 广东省| 基隆市| 乳山市| 读书| 赫章县| 浠水县| 临城县| 天峨县| 垣曲县| 新乡县| 高台县| 丽江市| 达拉特旗| 华安县| 玛纳斯县| 奉节县| 大同市| 九江县| 古蔺县| 绥江县| 大埔区| 牙克石市| 乾安县| 随州市| 额济纳旗| 阜平县| 垣曲县| 台北县| 河源市| 旬阳县| 敦煌市| 京山县| 平舆县| 神农架林区| 九龙县| 新龙县| 新和县| 六盘水市| 扎囊县| 鄄城县|