Starting to Implement Shake Action
This commit is contained in:
@@ -23,6 +23,9 @@ class AlarmActivationViewController: UIViewController
|
|||||||
@IBOutlet weak var rpsView: UIView!
|
@IBOutlet weak var rpsView: UIView!
|
||||||
@IBOutlet weak var rpsResult: UILabel!
|
@IBOutlet weak var rpsResult: UILabel!
|
||||||
|
|
||||||
|
//Shake Outlets
|
||||||
|
@IBOutlet weak var shakeView: UIView!
|
||||||
|
|
||||||
//Other Outlets
|
//Other Outlets
|
||||||
@IBOutlet weak var timeLabel: UILabel!
|
@IBOutlet weak var timeLabel: UILabel!
|
||||||
@IBOutlet weak var dateLabel: UILabel!
|
@IBOutlet weak var dateLabel: UILabel!
|
||||||
@@ -55,6 +58,7 @@ class AlarmActivationViewController: UIViewController
|
|||||||
//Hide all inactive wakemethods
|
//Hide all inactive wakemethods
|
||||||
puzzleView.isHidden = true
|
puzzleView.isHidden = true
|
||||||
rpsView.isHidden = true
|
rpsView.isHidden = true
|
||||||
|
shakeView.isHidden = true
|
||||||
|
|
||||||
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(AlarmActivationViewController.playSound), userInfo: nil, repeats: true)
|
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(AlarmActivationViewController.playSound), userInfo: nil, repeats: true)
|
||||||
setAlarmType()
|
setAlarmType()
|
||||||
@@ -85,6 +89,9 @@ class AlarmActivationViewController: UIViewController
|
|||||||
rpsView.isHidden = false
|
rpsView.isHidden = false
|
||||||
//Get Choice here
|
//Get Choice here
|
||||||
//rpsAction(choice: choice)
|
//rpsAction(choice: choice)
|
||||||
|
case "Shake":
|
||||||
|
shakeView.isHidden = false
|
||||||
|
shakeAction()
|
||||||
default:
|
default:
|
||||||
print("Invalid alarm type")
|
print("Invalid alarm type")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -665,6 +665,20 @@
|
|||||||
<constraint firstItem="eTb-g7-8x3" firstAttribute="top" secondItem="CZ0-R6-FDq" secondAttribute="bottom" constant="20" id="yME-j6-vSk"/>
|
<constraint firstItem="eTb-g7-8x3" firstAttribute="top" secondItem="CZ0-R6-FDq" secondAttribute="bottom" constant="20" id="yME-j6-vSk"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
</view>
|
</view>
|
||||||
|
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Zph-rd-rPI" userLabel="shakeView">
|
||||||
|
<rect key="frame" x="87" y="357" width="240" height="128"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="nK2-jK-GsP">
|
||||||
|
<rect key="frame" x="99" y="53" width="42" height="21"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
</subviews>
|
||||||
|
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
||||||
|
</view>
|
||||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="NmX-iJ-1D0" userLabel="rpsView">
|
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="NmX-iJ-1D0" userLabel="rpsView">
|
||||||
<rect key="frame" x="20" y="338.5" width="374" height="165"/>
|
<rect key="frame" x="20" y="338.5" width="374" height="165"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
@@ -748,6 +762,7 @@
|
|||||||
<outlet property="puzzleView" destination="OMQ-qK-fej" id="KLT-oe-RJX"/>
|
<outlet property="puzzleView" destination="OMQ-qK-fej" id="KLT-oe-RJX"/>
|
||||||
<outlet property="rpsResult" destination="HEP-oh-VSY" id="W2G-eZ-mzI"/>
|
<outlet property="rpsResult" destination="HEP-oh-VSY" id="W2G-eZ-mzI"/>
|
||||||
<outlet property="rpsView" destination="NmX-iJ-1D0" id="Rhg-Hm-2Xx"/>
|
<outlet property="rpsView" destination="NmX-iJ-1D0" id="Rhg-Hm-2Xx"/>
|
||||||
|
<outlet property="shakeView" destination="Zph-rd-rPI" id="aJ0-W7-cAV"/>
|
||||||
<outlet property="timeLabel" destination="vmg-Oj-8tB" id="FJJ-No-dwF"/>
|
<outlet property="timeLabel" destination="vmg-Oj-8tB" id="FJJ-No-dwF"/>
|
||||||
</connections>
|
</connections>
|
||||||
</viewController>
|
</viewController>
|
||||||
|
|||||||
@@ -198,6 +198,7 @@ class RPS {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Reference: https://youtu.be/XDuchXYiWuE
|
//Reference: https://youtu.be/XDuchXYiWuE
|
||||||
class Shake {
|
class Shake {
|
||||||
var motionManager = CMMotionManager()
|
var motionManager = CMMotionManager()
|
||||||
@@ -214,3 +215,4 @@ class Shake {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ struct WVM: Codable
|
|||||||
let wvms = [
|
let wvms = [
|
||||||
WVM(name: "Factor", desc: "Factor a binomial"),
|
WVM(name: "Factor", desc: "Factor a binomial"),
|
||||||
WVM(name: "RPS", desc: "Win a game of rock paper scissors"),
|
WVM(name: "RPS", desc: "Win a game of rock paper scissors"),
|
||||||
|
WVM(name: "Shake", desc: "Shake your phone... aggresively!"),
|
||||||
//WVM(name: "Smash", desc: "It'll never turn off"),
|
//WVM(name: "Smash", desc: "It'll never turn off"),
|
||||||
//WVM(name: "Walk", desc: "Walk a few steps"),
|
//WVM(name: "Walk", desc: "Walk a few steps"),
|
||||||
//WVM(name: "Jump", desc: "Make a few jumps")
|
//WVM(name: "Jump", desc: "Make a few jumps")
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ func jumpAction() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func shakeAction() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func rpsAction(choice: RPS.Choice) -> Bool? {
|
func rpsAction(choice: RPS.Choice) -> Bool? {
|
||||||
let rps = RPS()
|
let rps = RPS()
|
||||||
return rps.playRPS(you: choice, computer: RPS.randomComputerChoice())
|
return rps.playRPS(you: choice, computer: RPS.randomComputerChoice())
|
||||||
|
|||||||
Reference in New Issue
Block a user