From 35bff6638d59b9e2bada131ed9d08670923752b3 Mon Sep 17 00:00:00 2001 From: Ryunosuke-Kobayashi Date: Sat, 17 Dec 2022 00:04:26 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=A2=E3=82=B2=E3=82=8B=E6=A9=9F=E8=83=BD?= =?UTF-8?q?=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../p2hacks2022.xcodeproj/project.pbxproj | 6 + .../DoAgeruViewController.swift" | 147 ++++++++++++++++++ 2 files changed, 153 insertions(+) create mode 100644 "p2hacks2022/p2hacks2022/\343\202\242\343\202\262\343\202\213\346\272\226\345\202\231\347\224\273\351\235\242/DoAgeruViewController.swift" diff --git a/p2hacks2022/p2hacks2022.xcodeproj/project.pbxproj b/p2hacks2022/p2hacks2022.xcodeproj/project.pbxproj index a2090c7..3e9fba2 100644 --- a/p2hacks2022/p2hacks2022.xcodeproj/project.pbxproj +++ b/p2hacks2022/p2hacks2022.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 42D313AE294CB3080056FDBD /* DoAgeruViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42D313AD294CB3080056FDBD /* DoAgeruViewController.swift */; }; 7F1B1DA129473B0E0057D568 /* Agerareru.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7F1B1DA029473B0E0057D568 /* Agerareru.storyboard */; }; 7F1B1DA229473B0E0057D568 /* Agerareru.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7F1B1DA029473B0E0057D568 /* Agerareru.storyboard */; }; 7F1B1DA329473B0E0057D568 /* Agerareru.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7F1B1DA029473B0E0057D568 /* Agerareru.storyboard */; }; @@ -91,6 +92,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 42D313AD294CB3080056FDBD /* DoAgeruViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DoAgeruViewController.swift; sourceTree = ""; }; 7F1B1DA029473B0E0057D568 /* Agerareru.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Agerareru.storyboard; sourceTree = ""; }; 7F1B1DA429473B9B0057D568 /* PastAgeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PastAgeViewController.swift; sourceTree = ""; }; 7F1B1DA929473BC90057D568 /* PastAge.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = PastAge.storyboard; sourceTree = ""; }; @@ -228,6 +230,7 @@ 7FD113EE2949FB95007497BE /* AgeruPopup.storyboard */, 7F632F7F294BFFAE00578F01 /* RoomSelectViewController.swift */, 7F632F83294BFFB600578F01 /* RoomSelect.storyboard */, + 42D313AD294CB3080056FDBD /* DoAgeruViewController.swift */, ); name = "アゲる準備画面"; path = "アゲる準備画面"; @@ -434,6 +437,7 @@ 7F66CD6C294BCB7C0068BCEC /* CreateRoomViewController.swift in Sources */, 7F8BAA7929473A1A00AC32CB /* AgeruViewController.swift in Sources */, 7F1B1DA529473B9B0057D568 /* PastAgeViewController.swift in Sources */, + 42D313AE294CB3080056FDBD /* DoAgeruViewController.swift in Sources */, 7F8BAA8129473A4400AC32CB /* AgerareruViewController.swift in Sources */, 7F66CD5F294B63EC0068BCEC /* AgeruPubilcRoomViewController.swift in Sources */, 7F8BAA382944683900AC32CB /* AppDelegate.swift in Sources */, @@ -641,6 +645,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = NL67KBGNQ4; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = p2hacks2022/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "DO アゲ!"; @@ -669,6 +674,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = NL67KBGNQ4; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = p2hacks2022/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "DO アゲ!"; diff --git "a/p2hacks2022/p2hacks2022/\343\202\242\343\202\262\343\202\213\346\272\226\345\202\231\347\224\273\351\235\242/DoAgeruViewController.swift" "b/p2hacks2022/p2hacks2022/\343\202\242\343\202\262\343\202\213\346\272\226\345\202\231\347\224\273\351\235\242/DoAgeruViewController.swift" new file mode 100644 index 0000000..584f238 --- /dev/null +++ "b/p2hacks2022/p2hacks2022/\343\202\242\343\202\262\343\202\213\346\272\226\345\202\231\347\224\273\351\235\242/DoAgeruViewController.swift" @@ -0,0 +1,147 @@ +// +// DoAgeruViewController.swift +// p2hacks2022 +// +// Created by 小林龍ノ介 on 2022/12/16. +// + + +import SpriteKit +import GameplayKit +import CoreMotion +import UIKit + +class ViewController: UIViewController { + + var myMotionManager: CMMotionManager! + + var upCount = 0.0 + var timeCount = 11 //タイマー秒数指定 + var createTimer:Timer? + let numberLabel: UILabel = UILabel()//残り時間表示用のラベル + + + override func viewDidLoad() { + + super.viewDidLoad() + timerStart() //タイマー呼び出し + } + + + func timerStart() { + createTimer = Timer.scheduledTimer(timeInterval:1, //1秒毎指定 + target: self, + selector: #selector(self.countDown), + userInfo: nil, + repeats: true) + } + @objc func countDown(sender:Timer) { + timeCount -= 1 + if timeCount == 10 { + age() + } + //残り時間をラベルに表示 + if 0 (Int){ + if timeCount <= 0{ + return 1 + }else{ + return 0 + } + } + + @objc func age(){ + var count = 0 + + let countText: UILabel = UILabel() + countText.frame = CGRect(x: 0, y: 0, width: 200, height: 50) + countText.backgroundColor = UIColor.orange + countText.layer.masksToBounds = true + countText.layer.cornerRadius = 10.0 + countText.textColor = UIColor.white + countText.shadowColor = UIColor.gray + countText.textAlignment = NSTextAlignment.center + countText.layer.position = CGPoint(x: self.view.bounds.width/2,y: 280) + + + // ViewにLabelを追加. + self.view.addSubview(countText) + + // MotionManagerを生成. + myMotionManager = CMMotionManager() + + // 更新周期を設定. + + myMotionManager.accelerometerUpdateInterval = 0.8 + + var zdata = 0.0//(Double)(data.acceleration.z) + + + if upCountDown() == 0{ + // 加速度の取得を開始. + myMotionManager.startAccelerometerUpdates(to: OperationQueue.main, withHandler: {(accelerometerData, error) in + if let e = error { + print(e.localizedDescription) + return + } + guard let data = accelerometerData else { + return + } + + self.upCount += 0.8//何回この処理が繰り返されたか確認 + + if zdata != 1{ + if zdata - Double(data.acceleration.z) >= 0.06 || zdata - Double(data.acceleration.z) <= -0.06{ + count += 1 + print("zdata!=0: \(zdata)") + print(Double(data.acceleration.z)) + + zdata = Double(data.acceleration.z) + } + }else { + print("zdata=0\(zdata)") + print(Double(data.acceleration.z)) + zdata = Double(data.acceleration.z) + } + + countText.text = String("\(count)アゲ") + + if (round(self.upCount)) == 10.0{ + print("Bbbbbbbb") + self.myMotionManager.stopAccelerometerUpdates() + print(count) + } + }) + } + } + +}