diff --git "a/Icon\r" "b/Icon\r" new file mode 100644 index 0000000..e69de29 diff --git a/Shitty Volume Switcher.xcodeproj/project.pbxproj b/Shitty Volume Switcher.xcodeproj/project.pbxproj index 5350624..30926e7 100644 --- a/Shitty Volume Switcher.xcodeproj/project.pbxproj +++ b/Shitty Volume Switcher.xcodeproj/project.pbxproj @@ -9,7 +9,6 @@ /* Begin PBXBuildFile section */ 503FC2C923906B5500B8095B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 503FC2C823906B5500B8095B /* AppDelegate.swift */; }; 503FC2CB23906B5500B8095B /* GameScene.sks in Resources */ = {isa = PBXBuildFile; fileRef = 503FC2CA23906B5500B8095B /* GameScene.sks */; }; - 503FC2CD23906B5500B8095B /* Actions.sks in Resources */ = {isa = PBXBuildFile; fileRef = 503FC2CC23906B5500B8095B /* Actions.sks */; }; 503FC2CF23906B5500B8095B /* GameScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = 503FC2CE23906B5500B8095B /* GameScene.swift */; }; 503FC2D123906B5500B8095B /* GameViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 503FC2D023906B5500B8095B /* GameViewController.swift */; }; 503FC2D423906B5500B8095B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 503FC2D223906B5500B8095B /* Main.storyboard */; }; @@ -21,7 +20,6 @@ 503FC2C523906B5500B8095B /* Shitty Volume Switcher.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Shitty Volume Switcher.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 503FC2C823906B5500B8095B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 503FC2CA23906B5500B8095B /* GameScene.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; path = GameScene.sks; sourceTree = ""; }; - 503FC2CC23906B5500B8095B /* Actions.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; path = Actions.sks; sourceTree = ""; }; 503FC2CE23906B5500B8095B /* GameScene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameScene.swift; sourceTree = ""; }; 503FC2D023906B5500B8095B /* GameViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameViewController.swift; sourceTree = ""; }; 503FC2D323906B5500B8095B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; @@ -62,7 +60,6 @@ children = ( 503FC2C823906B5500B8095B /* AppDelegate.swift */, 503FC2CA23906B5500B8095B /* GameScene.sks */, - 503FC2CC23906B5500B8095B /* Actions.sks */, 503FC2CE23906B5500B8095B /* GameScene.swift */, 503FC2D023906B5500B8095B /* GameViewController.swift */, 503FC2D223906B5500B8095B /* Main.storyboard */, @@ -135,7 +132,6 @@ 503FC2CB23906B5500B8095B /* GameScene.sks in Resources */, 503FC2D623906B5800B8095B /* Assets.xcassets in Resources */, 503FC2D923906B5800B8095B /* LaunchScreen.storyboard in Resources */, - 503FC2CD23906B5500B8095B /* Actions.sks in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -293,7 +289,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 36JR976L6Y; + DEVELOPMENT_TEAM = T87U8Q4BB3; INFOPLIST_FILE = "Shitty Volume Switcher/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -311,7 +307,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 36JR976L6Y; + DEVELOPMENT_TEAM = T87U8Q4BB3; INFOPLIST_FILE = "Shitty Volume Switcher/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", diff --git a/Shitty Volume Switcher/Actions.sks b/Shitty Volume Switcher/Actions.sks deleted file mode 100644 index 0530520..0000000 Binary files a/Shitty Volume Switcher/Actions.sks and /dev/null differ diff --git a/Shitty Volume Switcher/Assets.xcassets/ball.imageset/Contents.json b/Shitty Volume Switcher/Assets.xcassets/ball.imageset/Contents.json new file mode 100644 index 0000000..9f21e36 --- /dev/null +++ b/Shitty Volume Switcher/Assets.xcassets/ball.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "ball.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "ball@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "ball@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Shitty Volume Switcher/Assets.xcassets/ball.imageset/ball.png b/Shitty Volume Switcher/Assets.xcassets/ball.imageset/ball.png new file mode 100644 index 0000000..6fef17e Binary files /dev/null and b/Shitty Volume Switcher/Assets.xcassets/ball.imageset/ball.png differ diff --git a/Shitty Volume Switcher/Assets.xcassets/ball.imageset/ball@2x.png b/Shitty Volume Switcher/Assets.xcassets/ball.imageset/ball@2x.png new file mode 100644 index 0000000..4c17809 Binary files /dev/null and b/Shitty Volume Switcher/Assets.xcassets/ball.imageset/ball@2x.png differ diff --git a/Shitty Volume Switcher/Assets.xcassets/ball.imageset/ball@3x.png b/Shitty Volume Switcher/Assets.xcassets/ball.imageset/ball@3x.png new file mode 100644 index 0000000..df5cef9 Binary files /dev/null and b/Shitty Volume Switcher/Assets.xcassets/ball.imageset/ball@3x.png differ diff --git a/Shitty Volume Switcher/Assets.xcassets/collider.imageset/Contents.json b/Shitty Volume Switcher/Assets.xcassets/collider.imageset/Contents.json new file mode 100644 index 0000000..6a37a7a --- /dev/null +++ b/Shitty Volume Switcher/Assets.xcassets/collider.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "collider.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "collider-1.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "collider-2.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Shitty Volume Switcher/Assets.xcassets/collider.imageset/collider-1.png b/Shitty Volume Switcher/Assets.xcassets/collider.imageset/collider-1.png new file mode 100644 index 0000000..f4cdd76 Binary files /dev/null and b/Shitty Volume Switcher/Assets.xcassets/collider.imageset/collider-1.png differ diff --git a/Shitty Volume Switcher/Assets.xcassets/collider.imageset/collider-2.png b/Shitty Volume Switcher/Assets.xcassets/collider.imageset/collider-2.png new file mode 100644 index 0000000..f4cdd76 Binary files /dev/null and b/Shitty Volume Switcher/Assets.xcassets/collider.imageset/collider-2.png differ diff --git a/Shitty Volume Switcher/Assets.xcassets/collider.imageset/collider.png b/Shitty Volume Switcher/Assets.xcassets/collider.imageset/collider.png new file mode 100644 index 0000000..f4cdd76 Binary files /dev/null and b/Shitty Volume Switcher/Assets.xcassets/collider.imageset/collider.png differ diff --git a/Shitty Volume Switcher/Assets.xcassets/wall.imageset/Contents.json b/Shitty Volume Switcher/Assets.xcassets/wall.imageset/Contents.json new file mode 100644 index 0000000..170d86d --- /dev/null +++ b/Shitty Volume Switcher/Assets.xcassets/wall.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "wall.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "wall-1.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "wall-2.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Shitty Volume Switcher/Assets.xcassets/wall.imageset/wall-1.png b/Shitty Volume Switcher/Assets.xcassets/wall.imageset/wall-1.png new file mode 100644 index 0000000..519f54b Binary files /dev/null and b/Shitty Volume Switcher/Assets.xcassets/wall.imageset/wall-1.png differ diff --git a/Shitty Volume Switcher/Assets.xcassets/wall.imageset/wall-2.png b/Shitty Volume Switcher/Assets.xcassets/wall.imageset/wall-2.png new file mode 100644 index 0000000..519f54b Binary files /dev/null and b/Shitty Volume Switcher/Assets.xcassets/wall.imageset/wall-2.png differ diff --git a/Shitty Volume Switcher/Assets.xcassets/wall.imageset/wall.png b/Shitty Volume Switcher/Assets.xcassets/wall.imageset/wall.png new file mode 100644 index 0000000..519f54b Binary files /dev/null and b/Shitty Volume Switcher/Assets.xcassets/wall.imageset/wall.png differ diff --git a/Shitty Volume Switcher/Base.lproj/Main.storyboard b/Shitty Volume Switcher/Base.lproj/Main.storyboard index 2cc971a..7eba9df 100644 --- a/Shitty Volume Switcher/Base.lproj/Main.storyboard +++ b/Shitty Volume Switcher/Base.lproj/Main.storyboard @@ -1,7 +1,8 @@ - + + - + @@ -9,16 +10,17 @@ - + - + - + + diff --git a/Shitty Volume Switcher/GameScene.sks b/Shitty Volume Switcher/GameScene.sks index 4fe4d9f..7490b42 100644 Binary files a/Shitty Volume Switcher/GameScene.sks and b/Shitty Volume Switcher/GameScene.sks differ diff --git a/Shitty Volume Switcher/GameScene.swift b/Shitty Volume Switcher/GameScene.swift index 2ad72f4..33f013d 100644 --- a/Shitty Volume Switcher/GameScene.swift +++ b/Shitty Volume Switcher/GameScene.swift @@ -8,82 +8,127 @@ import SpriteKit import GameplayKit +import CoreMotion +import MediaPlayer -class GameScene: SKScene { +var motionManager: CMMotionManager! + + +class GameScene: SKScene, SKPhysicsContactDelegate { private var label : SKLabelNode? - private var spinnyNode : SKShapeNode? + var lastTouchPosition: CGPoint? + var ball: SKSpriteNode! + + let ballCategory: UInt32 = 0x1 + + var button: SKNode! = nil + + override func didMove(to view: SKView) { + motionManager = CMMotionManager() + motionManager.startAccelerometerUpdates() - // Get label node from scene and store it for use later - self.label = self.childNode(withName: "//helloLabel") as? SKLabelNode - if let label = self.label { - label.alpha = 0.0 - label.run(SKAction.fadeIn(withDuration: 2.0)) - } + physicsWorld.contactDelegate = self - // Create shape node to use during mouse interaction - let w = (self.size.width + self.size.height) * 0.05 - self.spinnyNode = SKShapeNode.init(rectOf: CGSize.init(width: w, height: w), cornerRadius: w * 0.3) - if let spinnyNode = self.spinnyNode { - spinnyNode.lineWidth = 2.5 - - spinnyNode.run(SKAction.repeatForever(SKAction.rotate(byAngle: CGFloat(Double.pi), duration: 1))) - spinnyNode.run(SKAction.sequence([SKAction.wait(forDuration: 0.5), - SKAction.fadeOut(withDuration: 0.5), - SKAction.removeFromParent()])) - } - } - - - func touchDown(atPoint pos : CGPoint) { - if let n = self.spinnyNode?.copy() as! SKShapeNode? { - n.position = pos - n.strokeColor = SKColor.green - self.addChild(n) - } - } - - func touchMoved(toPoint pos : CGPoint) { - if let n = self.spinnyNode?.copy() as! SKShapeNode? { - n.position = pos - n.strokeColor = SKColor.blue - self.addChild(n) - } - } - - func touchUp(atPoint pos : CGPoint) { - if let n = self.spinnyNode?.copy() as! SKShapeNode? { - n.position = pos - n.strokeColor = SKColor.red - self.addChild(n) - } - } - - override func touchesBegan(_ touches: Set, with event: UIEvent?) { - if let label = self.label { - label.run(SKAction.init(named: "Pulse")!, withKey: "fadeInOut") - } - for t in touches { self.touchDown(atPoint: t.location(in: self)) } + +// let collider = SKSpriteNode(imageNamed: "collider") +// collider.setScale(2) +// collider.physicsBody = SKPhysicsBody(rectangleOf: collider.size) +// collider.physicsBody?.restitution = 0.4 +// collider.physicsBody?.isDynamic = false +// collider.position = CGPoint(x: 0, y: -150) +// collider.physicsBody?.linearDamping = 0.5 +// addChild(collider) + + physicsWorld.gravity = .zero + + ball = SKSpriteNode(imageNamed: "ball") + ball.setScale(2.5) + ball.physicsBody = SKPhysicsBody(circleOfRadius: ball.size.width / 2.0) + ball.physicsBody?.restitution = 0.7 + ball.position = CGPoint(x: 0, y: 0) + ball.physicsBody?.categoryBitMask = ballCategory + ball.zPosition = 5 + addChild(ball) } - override func touchesMoved(_ touches: Set, with event: UIEvent?) { - for t in touches { self.touchMoved(toPoint: t.location(in: self)) } + func didBegin(_ contact: SKPhysicsContact) { + let contactNode = contact.bodyA.node as! SKSpriteNode + MPVolumeView.setVolume(Float(contact.bodyA.contactTestBitMask)/31) + let scale = SKAction.scale(by: 0.7, duration: 0.15) + let reverseScale = scale.reversed() + let actions = [scale, reverseScale] + let sequence = SKAction.sequence(actions) + contactNode.run(sequence) + print(contact.bodyA.contactTestBitMask) +// print(contact.bodyB.categoryBitMask) +// if (contact.bodyA.categoryBitMask == 1) && +// (contact.bodyB.categoryBitMask == 2) { +// print("here") +// +// } } + +// override func touchesBegan(_ touches: Set, with event: UIEvent?) { +// guard let touch = touches.first else { return } +// let location = touch.location(in: self) +// lastTouchPosition = location +// } +// +// for t in touches { self.touchDown(atPoint: t.location(in: self)) } +// } +// +// override func touchesMoved(_ touches: Set, with event: UIEvent?) { +// guard let touch = touches.first else { return } +// let location = touch.location(in: self) +// lastTouchPosition = location +// } +// override func touchesEnded(_ touches: Set, with event: UIEvent?) { - for t in touches { self.touchUp(atPoint: t.location(in: self)) } - } - - override func touchesCancelled(_ touches: Set, with event: UIEvent?) { - for t in touches { self.touchUp(atPoint: t.location(in: self)) } +// lastTouchPosition = nil + let touch = touches.first + let touchLocation = touch!.location(in: self) + // Check if the location of the touch is within the button's bounds + if button.contains(touchLocation) { + MPVolumeView.setVolume(0.5) + } } +// +// override func touchesCancelled(_ touches: Set, with event: UIEvent?) { +// for t in touches { self.touchUp(atPoint: t.location(in: self)) } +// } override func update(_ currentTime: TimeInterval) { // Called before each frame is rendered + if let accelerometerData = motionManager.accelerometerData { + physicsWorld.gravity = CGVector(dx: accelerometerData.acceleration.y * 10, dy: accelerometerData.acceleration.x * -10) + } + + } + + +} + +extension MPVolumeView { + static func setVolume(_ volume: Float) { + // Need to use the MPVolumeView in order to change volume, but don't care about UI set so frame to .zero + let volumeView = MPVolumeView(frame: .zero) + // Search for the slider + let slider = volumeView.subviews.first(where: { $0 is UISlider }) as? UISlider + // Update the slider value with the desired volume. + DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.01) { + slider?.value = volume + } + // Optional - Remove the HUD +// if let app = UIApplication.shared.delegate as? AppDelegate, let window = app.window { +// volumeView.alpha = 0.000001 +// window.addSubview(volumeView) +// } } } diff --git a/Shitty Volume Switcher/Info.plist b/Shitty Volume Switcher/Info.plist index 870f784..e228172 100644 --- a/Shitty Volume Switcher/Info.plist +++ b/Shitty Volume Switcher/Info.plist @@ -32,9 +32,7 @@ UISupportedInterfaceOrientations - UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight UISupportedInterfaceOrientations~ipad