Skip to content
Snippets Groups Projects
Commit 402f1397 authored by Tobias Ullerich's avatar Tobias Ullerich
Browse files

Add sounds

parent 6129a2bf
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
F6090F531F1AA9270003F688 /* pause.png in Resources */ = {isa = PBXBuildFile; fileRef = F6090F521F1AA9270003F688 /* pause.png */; }; F6090F531F1AA9270003F688 /* pause.png in Resources */ = {isa = PBXBuildFile; fileRef = F6090F521F1AA9270003F688 /* pause.png */; };
F6090F561F1AAEB40003F688 /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F6090F551F1AAEB40003F688 /* MainViewController.swift */; };
F6090F5A1F1AAEED0003F688 /* pacman_beginning.wav in Resources */ = {isa = PBXBuildFile; fileRef = F6090F571F1AAEED0003F688 /* pacman_beginning.wav */; };
F6090F5B1F1AAEED0003F688 /* pacman_chomp.wav in Resources */ = {isa = PBXBuildFile; fileRef = F6090F581F1AAEED0003F688 /* pacman_chomp.wav */; };
F6090F5C1F1AAEED0003F688 /* pacman_death.wav in Resources */ = {isa = PBXBuildFile; fileRef = F6090F591F1AAEED0003F688 /* pacman_death.wav */; };
F6621DF41F12B09800F9E486 /* TouchInputHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = F6621DF31F12B09800F9E486 /* TouchInputHandler.swift */; }; F6621DF41F12B09800F9E486 /* TouchInputHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = F6621DF31F12B09800F9E486 /* TouchInputHandler.swift */; };
F6621DF61F12B82200F9E486 /* MotionInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = F6621DF51F12B82200F9E486 /* MotionInput.swift */; }; F6621DF61F12B82200F9E486 /* MotionInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = F6621DF51F12B82200F9E486 /* MotionInput.swift */; };
F6BEB8071EF7F99B00EDAA66 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F6BEB8061EF7F99B00EDAA66 /* AppDelegate.swift */; }; F6BEB8071EF7F99B00EDAA66 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F6BEB8061EF7F99B00EDAA66 /* AppDelegate.swift */; };
...@@ -49,6 +53,10 @@ ...@@ -49,6 +53,10 @@
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
F6090F521F1AA9270003F688 /* pause.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pause.png; sourceTree = "<group>"; }; F6090F521F1AA9270003F688 /* pause.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pause.png; sourceTree = "<group>"; };
F6090F551F1AAEB40003F688 /* MainViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = "<group>"; };
F6090F571F1AAEED0003F688 /* pacman_beginning.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = pacman_beginning.wav; sourceTree = "<group>"; };
F6090F581F1AAEED0003F688 /* pacman_chomp.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = pacman_chomp.wav; sourceTree = "<group>"; };
F6090F591F1AAEED0003F688 /* pacman_death.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = pacman_death.wav; sourceTree = "<group>"; };
F6621DF31F12B09800F9E486 /* TouchInputHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TouchInputHandler.swift; sourceTree = "<group>"; }; F6621DF31F12B09800F9E486 /* TouchInputHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TouchInputHandler.swift; sourceTree = "<group>"; };
F6621DF51F12B82200F9E486 /* MotionInput.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MotionInput.swift; sourceTree = "<group>"; }; F6621DF51F12B82200F9E486 /* MotionInput.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MotionInput.swift; sourceTree = "<group>"; };
F6BEB8031EF7F99B00EDAA66 /* Pacman3D-iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Pacman3D-iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; F6BEB8031EF7F99B00EDAA66 /* Pacman3D-iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Pacman3D-iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
...@@ -105,6 +113,9 @@ ...@@ -105,6 +113,9 @@
F6090F541F1AA92D0003F688 /* Resources */ = { F6090F541F1AA92D0003F688 /* Resources */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
F6090F571F1AAEED0003F688 /* pacman_beginning.wav */,
F6090F581F1AAEED0003F688 /* pacman_chomp.wav */,
F6090F591F1AAEED0003F688 /* pacman_death.wav */,
F6FEE71A1EF8135200C1DE35 /* level.plv */, F6FEE71A1EF8135200C1DE35 /* level.plv */,
F6E39CE11F1A56E500A3E7D1 /* wall.jpg */, F6E39CE11F1A56E500A3E7D1 /* wall.jpg */,
F6E39CE31F1A583B00A3E7D1 /* floor.jpg */, F6E39CE31F1A583B00A3E7D1 /* floor.jpg */,
...@@ -140,6 +151,7 @@ ...@@ -140,6 +151,7 @@
F6FEE7141EF80AB900C1DE35 /* Level */, F6FEE7141EF80AB900C1DE35 /* Level */,
F6FEE7191EF80C1900C1DE35 /* Uilts */, F6FEE7191EF80C1900C1DE35 /* Uilts */,
F6BEB8061EF7F99B00EDAA66 /* AppDelegate.swift */, F6BEB8061EF7F99B00EDAA66 /* AppDelegate.swift */,
F6090F551F1AAEB40003F688 /* MainViewController.swift */,
F6BEB80A1EF7F99B00EDAA66 /* GameViewController.swift */, F6BEB80A1EF7F99B00EDAA66 /* GameViewController.swift */,
F6621DF31F12B09800F9E486 /* TouchInputHandler.swift */, F6621DF31F12B09800F9E486 /* TouchInputHandler.swift */,
F6621DF51F12B82200F9E486 /* MotionInput.swift */, F6621DF51F12B82200F9E486 /* MotionInput.swift */,
...@@ -301,8 +313,11 @@ ...@@ -301,8 +313,11 @@
isa = PBXResourcesBuildPhase; isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
F6090F5B1F1AAEED0003F688 /* pacman_chomp.wav in Resources */,
F6090F5C1F1AAEED0003F688 /* pacman_death.wav in Resources */,
F6BEB8091EF7F99B00EDAA66 /* art.scnassets in Resources */, F6BEB8091EF7F99B00EDAA66 /* art.scnassets in Resources */,
F6E39CE41F1A583B00A3E7D1 /* floor.jpg in Resources */, F6E39CE41F1A583B00A3E7D1 /* floor.jpg in Resources */,
F6090F5A1F1AAEED0003F688 /* pacman_beginning.wav in Resources */,
F6BEB8131EF7F99B00EDAA66 /* LaunchScreen.storyboard in Resources */, F6BEB8131EF7F99B00EDAA66 /* LaunchScreen.storyboard in Resources */,
F6BEB8101EF7F99B00EDAA66 /* Assets.xcassets in Resources */, F6BEB8101EF7F99B00EDAA66 /* Assets.xcassets in Resources */,
F6BEB80E1EF7F99B00EDAA66 /* Main.storyboard in Resources */, F6BEB80E1EF7F99B00EDAA66 /* Main.storyboard in Resources */,
...@@ -335,6 +350,7 @@ ...@@ -335,6 +350,7 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
F6621DF61F12B82200F9E486 /* MotionInput.swift in Sources */, F6621DF61F12B82200F9E486 /* MotionInput.swift in Sources */,
F6090F561F1AAEB40003F688 /* MainViewController.swift in Sources */,
F6E4AE451F0CF1DF004BFDBF /* Direction.swift in Sources */, F6E4AE451F0CF1DF004BFDBF /* Direction.swift in Sources */,
F6FEE7181EF80C1500C1DE35 /* StreamReader.swift in Sources */, F6FEE7181EF80C1500C1DE35 /* StreamReader.swift in Sources */,
F6E39CEC1F1A7D5500A3E7D1 /* BorderButton.swift in Sources */, F6E39CEC1F1A7D5500A3E7D1 /* BorderButton.swift in Sources */,
......
...@@ -9,10 +9,10 @@ ...@@ -9,10 +9,10 @@
<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>
<scenes> <scenes>
<!--View Controller--> <!--Main View Controller-->
<scene sceneID="p6t-FQ-akW"> <scene sceneID="p6t-FQ-akW">
<objects> <objects>
<viewController id="uj1-yy-esL" sceneMemberID="viewController"> <viewController id="uj1-yy-esL" customClass="MainViewController" customModule="Pacman3D_iOS" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides> <layoutGuides>
<viewControllerLayoutGuide type="top" id="YLp-lV-ETO"/> <viewControllerLayoutGuide type="top" id="YLp-lV-ETO"/>
<viewControllerLayoutGuide type="bottom" id="h1R-Z6-Vqf"/> <viewControllerLayoutGuide type="bottom" id="h1R-Z6-Vqf"/>
......
...@@ -11,6 +11,7 @@ import QuartzCore ...@@ -11,6 +11,7 @@ import QuartzCore
import SceneKit import SceneKit
import SpriteKit import SpriteKit
import CoreMotion import CoreMotion
import AVFoundation
class GameViewController: UIViewController, SKSceneDelegate, SCNPhysicsContactDelegate, SCNSceneRendererDelegate, PlayerDelegate { class GameViewController: UIViewController, SKSceneDelegate, SCNPhysicsContactDelegate, SCNSceneRendererDelegate, PlayerDelegate {
...@@ -40,6 +41,10 @@ class GameViewController: UIViewController, SKSceneDelegate, SCNPhysicsContactDe ...@@ -40,6 +41,10 @@ class GameViewController: UIViewController, SKSceneDelegate, SCNPhysicsContactDe
var player: Player! var player: Player!
var monsters: [Monster]! var monsters: [Monster]!
// MARK: - Sounds
var soundChomp: AVAudioPlayer?
var soundDeath: AVAudioPlayer?
// MARK: - Input Handler // MARK: - Input Handler
private var touchInputHandler: TouchInputHandler! private var touchInputHandler: TouchInputHandler!
private var motionInput: MotionInput? private var motionInput: MotionInput?
...@@ -47,6 +52,15 @@ class GameViewController: UIViewController, SKSceneDelegate, SCNPhysicsContactDe ...@@ -47,6 +52,15 @@ class GameViewController: UIViewController, SKSceneDelegate, SCNPhysicsContactDe
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
if let url = Bundle.main.url(forResource: "pacman_chomp", withExtension: "wav") {
soundChomp = try? AVAudioPlayer(contentsOf: url)
soundChomp?.prepareToPlay()
}
if let url = Bundle.main.url(forResource: "pacman_death", withExtension: "wav") {
soundDeath = try? AVAudioPlayer(contentsOf: url)
soundDeath?.prepareToPlay()
}
monsters = [] monsters = []
level = Level(named: "level") level = Level(named: "level")
...@@ -158,6 +172,8 @@ class GameViewController: UIViewController, SKSceneDelegate, SCNPhysicsContactDe ...@@ -158,6 +172,8 @@ class GameViewController: UIViewController, SKSceneDelegate, SCNPhysicsContactDe
let monster = contact.nodeA.name ?? "" == "Monster" ? contact.nodeA : contact.nodeB let monster = contact.nodeA.name ?? "" == "Monster" ? contact.nodeA : contact.nodeB
monster.removeFromParentNode() monster.removeFromParentNode()
soundDeath?.play()
for m in monsters { for m in monsters {
if let n = m.node { if let n = m.node {
if n == monster { if n == monster {
...@@ -176,6 +192,7 @@ class GameViewController: UIViewController, SKSceneDelegate, SCNPhysicsContactDe ...@@ -176,6 +192,7 @@ class GameViewController: UIViewController, SKSceneDelegate, SCNPhysicsContactDe
func player(_ player: Player, scoreDidUpdate score: Int) { func player(_ player: Player, scoreDidUpdate score: Int) {
pointsLabel.text = "\(player.points) Punkte" pointsLabel.text = "\(player.points) Punkte"
soundChomp?.play()
} }
func player(_ player: Player, didCollectScoreAt position: (x: Int, z: Int)) { func player(_ player: Player, didCollectScoreAt position: (x: Int, z: Int)) {
......
//
// MainViewController.swift
// Pacman3D-iOS
//
// Created by Tobias on 15.07.17.
// Copyright © 2017 Tobias. All rights reserved.
//
import UIKit
import AVFoundation
class MainViewController: UIViewController {
var player: AVAudioPlayer?
override func viewDidLoad() {
super.viewDidLoad()
if let url = Bundle.main.url(forResource: "pacman_beginning", withExtension: "wav") {
player = try? AVAudioPlayer(contentsOf: url)
player?.numberOfLoops = -1
player?.prepareToPlay()
}
}
override func viewDidAppear(_ animated: Bool) {
player?.play()
}
override func viewWillDisappear(_ animated: Bool) {
player?.stop()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
File added
File added
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment