SingleModeViewController.swift 1.32 KB
Newer Older
Mobile Roshka committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
//
//  singleMode.swift
//  juego
//
//  Created by Mobile Roshka on 3/4/20.
//  Copyright © 2020 Mobile Roshka. All rights reserved.
//

import UIKit

class SingleModeViewController: UIViewController {
    var points = 0
    var initGame = false
    var initTimer = false
    var timer = Timer()
    var timeRest = 10

    
    

    @IBOutlet weak var pointsLbl: UILabel!
    @IBOutlet weak var timeRestLbl: UILabel!
    
  

    @IBAction func playGame(_ sender: Any) {
        initGame = true
        initTimer = true
        timeRest = 10
        timeRestLbl.text = "\(timeRest)"
        if initTimer{
            timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(timeRestMethod), userInfo :nil, repeats: true)
        }
        
        
    }

     @objc func timeRestMethod()
     {
         
        timeRest -= 1
        timeRestLbl.text = "\(timeRest)"
        if timeRest == 0 {
            timer.invalidate()
            initGame = false
        }

     }
    @IBAction func touchBtn(_ sender: Any) {
        
        
        
        if initGame{
            points += 1
            pointsLbl.text = "\(points)"
            
        }
        
    
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }
    



}