Working on shaking
This commit is contained in:
@@ -92,6 +92,9 @@ class AlarmActivationViewController: UIViewController
|
|||||||
case "Shake":
|
case "Shake":
|
||||||
shakeView.isHidden = false
|
shakeView.isHidden = false
|
||||||
shakeAction()
|
shakeAction()
|
||||||
|
if regulate {
|
||||||
|
endAlarm()
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
print("Invalid alarm type")
|
print("Invalid alarm type")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ class RPS {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
//Reference: https://youtu.be/XDuchXYiWuE
|
//Reference: https://youtu.be/XDuchXYiWuE
|
||||||
class Shake {
|
class Shake {
|
||||||
var motionManager = CMMotionManager()
|
var motionManager = CMMotionManager()
|
||||||
@@ -215,4 +215,4 @@ class Shake {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ import CoreMotion
|
|||||||
import UserNotifications
|
import UserNotifications
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
|
var motionManager = CMMotionManager()
|
||||||
|
var regulate = true
|
||||||
|
|
||||||
func walkAction() {
|
func walkAction() {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -19,7 +22,20 @@ func jumpAction() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func shakeAction() {
|
func shakeAction() {
|
||||||
|
regulate = true
|
||||||
|
|
||||||
|
while regulate {
|
||||||
|
motionManager.accelerometerUpdateInterval = 0.2
|
||||||
|
|
||||||
|
motionManager.startAccelerometerUpdates(to: OperationQueue.current!) { (data,error) in
|
||||||
|
if let myData = data {
|
||||||
|
if myData.acceleration.x > 5 {
|
||||||
|
print("DO SOMETHING SPECIAL")
|
||||||
|
regulate = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func rpsAction(choice: RPS.Choice) -> Bool? {
|
func rpsAction(choice: RPS.Choice) -> Bool? {
|
||||||
|
|||||||
Reference in New Issue
Block a user