134 lines
4.1 KiB
Swift
134 lines
4.1 KiB
Swift
|
|
//
|
|
// GameLearnViewController.swift
|
|
// Guibe
|
|
//
|
|
// Created by Max Hunt on 11/06/2019.
|
|
// Copyright © 2019 8. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
import AVKit
|
|
|
|
class GameLearnViewController: UIViewController {
|
|
|
|
@IBOutlet weak var mainButton: UIButton!
|
|
@IBOutlet weak var textLabel: UILabel!
|
|
@IBOutlet weak var progressBar: UIProgressView!
|
|
@IBOutlet weak var nextBtn: UIButton!
|
|
|
|
@IBAction func buttonPressed(_ sender: Any) {
|
|
|
|
}
|
|
@IBAction func nextBtnPressed(_ sender: Any) {
|
|
stepCounter += 1
|
|
stepThrough(ptr: stepCounter)
|
|
}
|
|
|
|
var stepCounter: Int = 0
|
|
|
|
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
|
|
textLabel.text = "Now we will .......\n........."
|
|
|
|
|
|
// Do any additional setup after loading the view.
|
|
}
|
|
|
|
func stepThrough(ptr:Int) {
|
|
switch ptr {
|
|
case 1:
|
|
beginJourney()
|
|
case 2:
|
|
arrivedAtDestination()
|
|
case 3:
|
|
wrongDirection()
|
|
case 4:
|
|
turnRight()
|
|
case 5:
|
|
turnLeft()
|
|
case 6:
|
|
showDone()
|
|
case 7:
|
|
nextPage()
|
|
default:
|
|
return
|
|
}
|
|
}
|
|
|
|
func beginJourney() {
|
|
self.textLabel.fadeTransition(0.5)
|
|
self.textLabel.text = "This means \n'begin journey'"
|
|
self.mainButton.setTitle("Try me", for: .normal)
|
|
self.progressBar.setProgress(0.2, animated: true)
|
|
self.textLabel.accessibilityLabel = "This means begin journey"
|
|
self.mainButton.accessibilityLabel = "Try me"
|
|
}
|
|
|
|
func arrivedAtDestination() {
|
|
self.textLabel.fadeTransition(0.5)
|
|
self.textLabel.text = "This means \n'arrived at destination'"
|
|
self.mainButton.setTitle("Try me", for: .normal)
|
|
self.progressBar.setProgress(0.4, animated: true)
|
|
self.textLabel.accessibilityLabel = "This means arrived at destination"
|
|
self.mainButton.accessibilityLabel = "Try me"
|
|
}
|
|
|
|
func wrongDirection() {
|
|
self.textLabel.fadeTransition(0.5)
|
|
self.textLabel.text = "This means \n'you're walking in the wrong direction'"
|
|
self.mainButton.setTitle("Try me", for: .normal)
|
|
self.progressBar.setProgress(0.6, animated: true)
|
|
self.textLabel.accessibilityLabel = "This means you're walking in the wrong direction"
|
|
self.mainButton.accessibilityLabel = "Try me"
|
|
}
|
|
|
|
func turnRight() {
|
|
self.textLabel.fadeTransition(0.5)
|
|
self.textLabel.text = "This means \n'turn right'"
|
|
self.mainButton.setTitle("Try me", for: .normal)
|
|
self.progressBar.setProgress(0.8, animated: true)
|
|
self.textLabel.accessibilityLabel = "This means turn right"
|
|
self.mainButton.accessibilityLabel = "Try me"
|
|
}
|
|
|
|
func turnLeft() {
|
|
self.textLabel.fadeTransition(0.5)
|
|
self.textLabel.text = "This means \n'begin journey'"
|
|
self.mainButton.setTitle("Try me", for: .normal)
|
|
self.progressBar.setProgress(1.0, animated: true)
|
|
self.textLabel.accessibilityLabel = "This means turn left"
|
|
self.mainButton.accessibilityLabel = "Try me"
|
|
}
|
|
|
|
func showDone() {
|
|
self.textLabel.fadeTransition(0.5)
|
|
self.textLabel.text = "You are finished"
|
|
self.mainButton.alpha = 0.0
|
|
self.progressBar.alpha = 0.0
|
|
self.textLabel.accessibilityLabel = "You are finished"
|
|
self.mainButton.accessibilityLabel = "Try me"
|
|
}
|
|
|
|
func nextPage() {
|
|
let nextViewController = self.storyboard?.instantiateViewController(withIdentifier: "screen7") as! R7adyViewController
|
|
nextViewController.modalTransitionStyle = .crossDissolve
|
|
self.present(nextViewController, animated: true, completion: nil)
|
|
}
|
|
|
|
}
|
|
|
|
extension UIView {
|
|
|
|
func fadeTransition(_ duration:CFTimeInterval) {
|
|
let animation = CATransition()
|
|
animation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut)
|
|
animation.type = CATransitionType.fade
|
|
animation.duration = duration
|
|
layer.add(animation, forKey: CATransitionType.fade.rawValue)
|
|
}
|
|
}
|