add SettingsScene with background and music also boolean query for multiple audioplayer start
This commit is contained in:
parent
9c990cc897
commit
888d194676
@ -47,6 +47,7 @@
|
|||||||
ABA03DA0244BD54F00A66916 /* Base.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABA03D9F244BD54F00A66916 /* Base.swift */; };
|
ABA03DA0244BD54F00A66916 /* Base.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABA03D9F244BD54F00A66916 /* Base.swift */; };
|
||||||
AE151589245F18EF001D363E /* MatchmakingHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE151588245F18EF001D363E /* MatchmakingHelper.swift */; };
|
AE151589245F18EF001D363E /* MatchmakingHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE151588245F18EF001D363E /* MatchmakingHelper.swift */; };
|
||||||
C04783EE2468583F004961FB /* intro-music.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = C04783ED2468583F004961FB /* intro-music.mp3 */; };
|
C04783EE2468583F004961FB /* intro-music.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = C04783ED2468583F004961FB /* intro-music.mp3 */; };
|
||||||
|
C04783F024685995004961FB /* SettingsScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04783EF24685995004961FB /* SettingsScene.swift */; };
|
||||||
C05FAED62468559D0006AF2E /* SoundManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = C05FAED52468559D0006AF2E /* SoundManager.swift */; };
|
C05FAED62468559D0006AF2E /* SoundManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = C05FAED52468559D0006AF2E /* SoundManager.swift */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
@ -106,6 +107,7 @@
|
|||||||
ABA03D9F244BD54F00A66916 /* Base.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Base.swift; sourceTree = "<group>"; };
|
ABA03D9F244BD54F00A66916 /* Base.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Base.swift; sourceTree = "<group>"; };
|
||||||
AE151588245F18EF001D363E /* MatchmakingHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatchmakingHelper.swift; sourceTree = "<group>"; };
|
AE151588245F18EF001D363E /* MatchmakingHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatchmakingHelper.swift; sourceTree = "<group>"; };
|
||||||
C04783ED2468583F004961FB /* intro-music.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = "intro-music.mp3"; sourceTree = "<group>"; };
|
C04783ED2468583F004961FB /* intro-music.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = "intro-music.mp3"; sourceTree = "<group>"; };
|
||||||
|
C04783EF24685995004961FB /* SettingsScene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsScene.swift; sourceTree = "<group>"; };
|
||||||
C05FAED52468559D0006AF2E /* SoundManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SoundManager.swift; sourceTree = "<group>"; };
|
C05FAED52468559D0006AF2E /* SoundManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SoundManager.swift; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
@ -166,6 +168,7 @@
|
|||||||
110360E4244B101B008610AF /* Info.plist */,
|
110360E4244B101B008610AF /* Info.plist */,
|
||||||
AE151588245F18EF001D363E /* MatchmakingHelper.swift */,
|
AE151588245F18EF001D363E /* MatchmakingHelper.swift */,
|
||||||
3EBD242B245D8044003CECE7 /* GameCenterHelper.swift */,
|
3EBD242B245D8044003CECE7 /* GameCenterHelper.swift */,
|
||||||
|
C04783EF24685995004961FB /* SettingsScene.swift */,
|
||||||
);
|
);
|
||||||
path = GoldWars;
|
path = GoldWars;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -379,6 +382,7 @@
|
|||||||
9EA3ABEB245C6DFA006BC61D /* BaseNode.swift in Sources */,
|
9EA3ABEB245C6DFA006BC61D /* BaseNode.swift in Sources */,
|
||||||
9E04AFAF245E2B73002D5CFC /* AttackActionComponent.swift in Sources */,
|
9E04AFAF245E2B73002D5CFC /* AttackActionComponent.swift in Sources */,
|
||||||
110360D9244B101A008610AF /* GameScene.swift in Sources */,
|
110360D9244B101A008610AF /* GameScene.swift in Sources */,
|
||||||
|
C04783F024685995004961FB /* SettingsScene.swift in Sources */,
|
||||||
116060F7245C57D2004E5A36 /* EntityManager.swift in Sources */,
|
116060F7245C57D2004E5A36 /* EntityManager.swift in Sources */,
|
||||||
3EBD242E245D9332003CECE7 /* Team.swift in Sources */,
|
3EBD242E245D9332003CECE7 /* Team.swift in Sources */,
|
||||||
9E174C88245DF1FF00209FF0 /* BackgroundComponent.swift in Sources */,
|
9E174C88245DF1FF00209FF0 /* BackgroundComponent.swift in Sources */,
|
||||||
|
@ -35,10 +35,13 @@ class MenuScene: SKScene {
|
|||||||
position: CGPoint(x: midX, y: midY - 80 ),
|
position: CGPoint(x: midX, y: midY - 80 ),
|
||||||
onButtonPress: {
|
onButtonPress: {
|
||||||
//TODO: create Settings Scene
|
//TODO: create Settings Scene
|
||||||
|
self.loadScene(scene: SettingsScene(size: self.size))
|
||||||
}))
|
}))
|
||||||
entityManager.add(Background(size: self.size))
|
entityManager.add(Background(size: self.size))
|
||||||
|
|
||||||
soundManager.startMenuMusic()
|
if soundManager.isMusicPlaying == false {
|
||||||
|
soundManager.startMenuMusic()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadScene(scene: SKScene) {
|
func loadScene(scene: SKScene) {
|
||||||
|
40
GoldWars/GoldWars/SettingsScene.swift
Normal file
40
GoldWars/GoldWars/SettingsScene.swift
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
//
|
||||||
|
// SettingsScene.swift
|
||||||
|
// GoldWars
|
||||||
|
//
|
||||||
|
// Created by Tim Herbst on 10.05.20.
|
||||||
|
// Copyright © 2020 SP2. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SpriteKit
|
||||||
|
|
||||||
|
class SettingsScene: SKScene {
|
||||||
|
|
||||||
|
var entityManager: EntityManager!
|
||||||
|
|
||||||
|
override func sceneDidLoad() {
|
||||||
|
entityManager = EntityManager(scene: self)
|
||||||
|
let positionX = self.size.width * 0.1
|
||||||
|
let positionY = self.size.height * 0.1
|
||||||
|
|
||||||
|
entityManager.add(Button(name: "backToMenuScene",
|
||||||
|
iconName: "",
|
||||||
|
text: "Back",
|
||||||
|
position: CGPoint(x: positionX, y: positionY),
|
||||||
|
onButtonPress: {
|
||||||
|
self.loadScene(scene: MenuScene(size: self.size))
|
||||||
|
}))
|
||||||
|
|
||||||
|
entityManager.add(Background(size: self.size))
|
||||||
|
}
|
||||||
|
|
||||||
|
func loadScene(scene: SKScene) {
|
||||||
|
let transition = SKTransition.flipVertical(withDuration: 0.5)
|
||||||
|
self.view?.presentScene(scene, transition: transition)
|
||||||
|
}
|
||||||
|
|
||||||
|
override func update(_ currentTime: TimeInterval) {
|
||||||
|
entityManager.getBackground()!.update(deltaTime: currentTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -12,6 +12,7 @@ import AVFoundation
|
|||||||
class SoundManager {
|
class SoundManager {
|
||||||
var audioPlayer = AVAudioPlayer()
|
var audioPlayer = AVAudioPlayer()
|
||||||
var backgroundMainMenuAudio: URL?
|
var backgroundMainMenuAudio: URL?
|
||||||
|
var isMusicPlaying: Bool = false
|
||||||
|
|
||||||
func startMenuMusic() {
|
func startMenuMusic() {
|
||||||
backgroundMainMenuAudio = Bundle.main.url(forResource: "intro-music", withExtension: "mp3")
|
backgroundMainMenuAudio = Bundle.main.url(forResource: "intro-music", withExtension: "mp3")
|
||||||
@ -23,5 +24,11 @@ class SoundManager {
|
|||||||
audioPlayer.numberOfLoops = -1
|
audioPlayer.numberOfLoops = -1
|
||||||
audioPlayer.prepareToPlay()
|
audioPlayer.prepareToPlay()
|
||||||
audioPlayer.play()
|
audioPlayer.play()
|
||||||
|
isMusicPlaying = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func stopMenuMusic() {
|
||||||
|
audioPlayer.pause()
|
||||||
|
isMusicPlaying = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user