This commit is contained in:
Max Hunt 2019-12-02 13:48:43 +00:00
parent 2390f0f3e5
commit 8aaa013fc6
19 changed files with 181 additions and 71 deletions

0
Icon Normal file
View File

View File

@ -9,7 +9,6 @@
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
503FC2C923906B5500B8095B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 503FC2C823906B5500B8095B /* AppDelegate.swift */; }; 503FC2C923906B5500B8095B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 503FC2C823906B5500B8095B /* AppDelegate.swift */; };
503FC2CB23906B5500B8095B /* GameScene.sks in Resources */ = {isa = PBXBuildFile; fileRef = 503FC2CA23906B5500B8095B /* GameScene.sks */; }; 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 */; }; 503FC2CF23906B5500B8095B /* GameScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = 503FC2CE23906B5500B8095B /* GameScene.swift */; };
503FC2D123906B5500B8095B /* GameViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 503FC2D023906B5500B8095B /* GameViewController.swift */; }; 503FC2D123906B5500B8095B /* GameViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 503FC2D023906B5500B8095B /* GameViewController.swift */; };
503FC2D423906B5500B8095B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 503FC2D223906B5500B8095B /* Main.storyboard */; }; 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; }; 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 = "<group>"; }; 503FC2C823906B5500B8095B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
503FC2CA23906B5500B8095B /* GameScene.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; path = GameScene.sks; sourceTree = "<group>"; }; 503FC2CA23906B5500B8095B /* GameScene.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; path = GameScene.sks; sourceTree = "<group>"; };
503FC2CC23906B5500B8095B /* Actions.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; path = Actions.sks; sourceTree = "<group>"; };
503FC2CE23906B5500B8095B /* GameScene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameScene.swift; sourceTree = "<group>"; }; 503FC2CE23906B5500B8095B /* GameScene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameScene.swift; sourceTree = "<group>"; };
503FC2D023906B5500B8095B /* GameViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameViewController.swift; sourceTree = "<group>"; }; 503FC2D023906B5500B8095B /* GameViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameViewController.swift; sourceTree = "<group>"; };
503FC2D323906B5500B8095B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; }; 503FC2D323906B5500B8095B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
@ -62,7 +60,6 @@
children = ( children = (
503FC2C823906B5500B8095B /* AppDelegate.swift */, 503FC2C823906B5500B8095B /* AppDelegate.swift */,
503FC2CA23906B5500B8095B /* GameScene.sks */, 503FC2CA23906B5500B8095B /* GameScene.sks */,
503FC2CC23906B5500B8095B /* Actions.sks */,
503FC2CE23906B5500B8095B /* GameScene.swift */, 503FC2CE23906B5500B8095B /* GameScene.swift */,
503FC2D023906B5500B8095B /* GameViewController.swift */, 503FC2D023906B5500B8095B /* GameViewController.swift */,
503FC2D223906B5500B8095B /* Main.storyboard */, 503FC2D223906B5500B8095B /* Main.storyboard */,
@ -135,7 +132,6 @@
503FC2CB23906B5500B8095B /* GameScene.sks in Resources */, 503FC2CB23906B5500B8095B /* GameScene.sks in Resources */,
503FC2D623906B5800B8095B /* Assets.xcassets in Resources */, 503FC2D623906B5800B8095B /* Assets.xcassets in Resources */,
503FC2D923906B5800B8095B /* LaunchScreen.storyboard in Resources */, 503FC2D923906B5800B8095B /* LaunchScreen.storyboard in Resources */,
503FC2CD23906B5500B8095B /* Actions.sks in Resources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -293,7 +289,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 36JR976L6Y; DEVELOPMENT_TEAM = T87U8Q4BB3;
INFOPLIST_FILE = "Shitty Volume Switcher/Info.plist"; INFOPLIST_FILE = "Shitty Volume Switcher/Info.plist";
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
@ -311,7 +307,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 36JR976L6Y; DEVELOPMENT_TEAM = T87U8Q4BB3;
INFOPLIST_FILE = "Shitty Volume Switcher/Info.plist"; INFOPLIST_FILE = "Shitty Volume Switcher/Info.plist";
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",

Binary file not shown.

View File

@ -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"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 994 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -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"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View File

@ -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"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BV1-FR-VrT"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BV1-FR-VrT">
<device id="retina6_5" orientation="landscape" appearance="light"/>
<dependencies> <dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15510"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/> <capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
@ -9,16 +10,17 @@
<!--Game View Controller--> <!--Game View Controller-->
<scene sceneID="tXr-a1-R10"> <scene sceneID="tXr-a1-R10">
<objects> <objects>
<viewController id="BV1-FR-VrT" customClass="GameViewController" customModuleProvider="target" sceneMemberID="viewController"> <viewController id="BV1-FR-VrT" customClass="GameViewController" customModule="Shitty_Volume_Switcher" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" multipleTouchEnabled="YES" contentMode="scaleToFill" id="3se-qz-xqx" customClass="SKView"> <view key="view" multipleTouchEnabled="YES" contentMode="scaleToFill" id="3se-qz-xqx" customClass="SKView">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/> <rect key="frame" x="0.0" y="0.0" width="896" height="414"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="4qk-I5-YsI"/> <viewLayoutGuide key="safeArea" id="4qk-I5-YsI"/>
</view> </view>
</viewController> </viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="SZV-WD-TEh" sceneMemberID="firstResponder"/> <placeholder placeholderIdentifier="IBFirstResponder" id="SZV-WD-TEh" sceneMemberID="firstResponder"/>
</objects> </objects>
<point key="canvasLocation" x="138.61607142857142" y="137.68115942028987"/>
</scene> </scene>
</scenes> </scenes>
</document> </document>

Binary file not shown.

View File

@ -8,82 +8,127 @@
import SpriteKit import SpriteKit
import GameplayKit import GameplayKit
import CoreMotion
import MediaPlayer
class GameScene: SKScene { var motionManager: CMMotionManager!
class GameScene: SKScene, SKPhysicsContactDelegate {
private var label : SKLabelNode? 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) { override func didMove(to view: SKView) {
motionManager = CMMotionManager()
motionManager.startAccelerometerUpdates()
// Get label node from scene and store it for use later physicsWorld.contactDelegate = self
self.label = self.childNode(withName: "//helloLabel") as? SKLabelNode
if let label = self.label {
label.alpha = 0.0
label.run(SKAction.fadeIn(withDuration: 2.0))
}
// 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<UITouch>, 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<UITouch>, with event: UIEvent?) { func didBegin(_ contact: SKPhysicsContact) {
for t in touches { self.touchMoved(toPoint: t.location(in: self)) } 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<UITouch>, 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<UITouch>, with event: UIEvent?) {
// guard let touch = touches.first else { return }
// let location = touch.location(in: self)
// lastTouchPosition = location
// }
//
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) { override func touchesEnded(_ touches: Set<UITouch>, 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)
override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) { // Check if the location of the touch is within the button's bounds
for t in touches { self.touchUp(atPoint: t.location(in: self)) } if button.contains(touchLocation) {
MPVolumeView.setVolume(0.5)
}
} }
//
// override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
// for t in touches { self.touchUp(atPoint: t.location(in: self)) }
// }
override func update(_ currentTime: TimeInterval) { override func update(_ currentTime: TimeInterval) {
// Called before each frame is rendered // 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)
// }
} }
} }

View File

@ -32,9 +32,7 @@
<true/> <true/>
<key>UISupportedInterfaceOrientations</key> <key>UISupportedInterfaceOrientations</key>
<array> <array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array> </array>
<key>UISupportedInterfaceOrientations~ipad</key> <key>UISupportedInterfaceOrientations~ipad</key>
<array> <array>