diff --git a/DouShouQi_App/DouShouQi_App.xcodeproj/project.pbxproj b/DouShouQi_App/DouShouQi_App.xcodeproj/project.pbxproj index 5584a47..13e4fcf 100644 --- a/DouShouQi_App/DouShouQi_App.xcodeproj/project.pbxproj +++ b/DouShouQi_App/DouShouQi_App.xcodeproj/project.pbxproj @@ -38,6 +38,8 @@ EC62C4FF2C0457AD0048CD0B /* TitleScreenMusic.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = EC62C4FE2C0457AD0048CD0B /* TitleScreenMusic.mp3 */; }; EC62C5012C045B590048CD0B /* SoundPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C5002C045B590048CD0B /* SoundPlayer.swift */; }; EC62C5062C045C1A0048CD0B /* TitleScreenButtonSound.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = EC62C5052C045C1A0048CD0B /* TitleScreenButtonSound.mp3 */; }; + EC62C5092C0467240048CD0B /* SplashScreenView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C5082C0467240048CD0B /* SplashScreenView.swift */; }; + EC62C50D2C046D9E0048CD0B /* SplashScreenSound.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = EC62C50C2C046D9E0048CD0B /* SplashScreenSound.mp3 */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -106,6 +108,8 @@ EC62C4FE2C0457AD0048CD0B /* TitleScreenMusic.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = TitleScreenMusic.mp3; sourceTree = ""; }; EC62C5002C045B590048CD0B /* SoundPlayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SoundPlayer.swift; sourceTree = ""; }; EC62C5052C045C1A0048CD0B /* TitleScreenButtonSound.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = TitleScreenButtonSound.mp3; sourceTree = ""; }; + EC62C5082C0467240048CD0B /* SplashScreenView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashScreenView.swift; sourceTree = ""; }; + EC62C50C2C046D9E0048CD0B /* SplashScreenSound.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = SplashScreenSound.mp3; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -243,6 +247,7 @@ isa = PBXGroup; children = ( 649ABF5A2BF60D78002E8894 /* MainMenuView.swift */, + EC62C5082C0467240048CD0B /* SplashScreenView.swift */, ); path = Menu; sourceTree = ""; @@ -321,6 +326,7 @@ EC62C5032C045BD30048CD0B /* Sounds */ = { isa = PBXGroup; children = ( + EC62C50C2C046D9E0048CD0B /* SplashScreenSound.mp3 */, EC62C5052C045C1A0048CD0B /* TitleScreenButtonSound.mp3 */, ); path = Sounds; @@ -443,6 +449,7 @@ 6493C1C02C046BF900B5121D /* samurai.ttf in Resources */, EC62C5062C045C1A0048CD0B /* TitleScreenButtonSound.mp3 in Resources */, 649B59AC2BF64E12002BAE38 /* Images.xcassets in Resources */, + EC62C50D2C046D9E0048CD0B /* SplashScreenSound.mp3 in Resources */, 645834632BF5F92500E18321 /* Preview Assets.xcassets in Resources */, 645834602BF5F92500E18321 /* Assets.xcassets in Resources */, EC62C4FF2C0457AD0048CD0B /* TitleScreenMusic.mp3 in Resources */, @@ -481,6 +488,7 @@ 643AB6932BFCEFD00018DA73 /* GameResumeFrame.swift in Sources */, EC62C4EF2BFE367F0048CD0B /* SwiftUIView.swift in Sources */, 649B59B22BF65392002BAE38 /* TextStyles.swift in Sources */, + EC62C5092C0467240048CD0B /* SplashScreenView.swift in Sources */, EC62C4F92C0371660048CD0B /* MusicPlayer.swift in Sources */, EC62C4FD2C0391D30048CD0B /* PlayerRow.swift in Sources */, EC62C4FB2C038BD20048CD0B /* PlayersView.swift in Sources */, diff --git a/DouShouQi_App/DouShouQi_App/Assets/Sounds/SplashScreenSound.mp3 b/DouShouQi_App/DouShouQi_App/Assets/Sounds/SplashScreenSound.mp3 new file mode 100644 index 0000000..9c5c9d1 Binary files /dev/null and b/DouShouQi_App/DouShouQi_App/Assets/Sounds/SplashScreenSound.mp3 differ diff --git a/DouShouQi_App/DouShouQi_App/Views/Menu/MainMenuView.swift b/DouShouQi_App/DouShouQi_App/Views/Menu/MainMenuView.swift index d192947..6a893d5 100644 --- a/DouShouQi_App/DouShouQi_App/Views/Menu/MainMenuView.swift +++ b/DouShouQi_App/DouShouQi_App/Views/Menu/MainMenuView.swift @@ -8,57 +8,69 @@ import SwiftUI struct MainMenuView: View { + + @State private var showSplash = true + var body: some View { NavigationView { VStack { - - TitlePageFrame(Text: "DOU SHOU QI", ImageWidth: 200, ImageHeight: 200) - - Spacer() - - VStack { - HStack{ - VStack(spacing: 25) { - MainMenuButton(text: "Play", destination: ScoreBoardView(), sound: "TitleScreenButtonSound", horizontalAlignment: .leading, topRightCorner: 10, bottomRightCorner: 10) - MainMenuButton(text: "Historique", destination: HistoricView(), sound: "TitleScreenButtonSound", horizontalAlignment: .leading, topRightCorner: 10, bottomRightCorner: 10) - MainMenuButton(text: "Best Scores", destination: ScoreBoardView(), sound: "TitleScreenButtonSound", horizontalAlignment: .leading, topRightCorner: 10, bottomRightCorner: 10) - MainMenuButton(text: "Players", destination: PlayersView(), sound: "TitleScreenButtonSound", horizontalAlignment: .leading, topRightCorner: 10, bottomRightCorner: 10) + if showSplash { + SplashScreenView() + .transition(.opacity) + .animation(.easeOut(duration: 3), value: showSplash) + .onAppear { + DispatchQueue.main.asyncAfter(deadline: .now() + 8) { + withAnimation { + showSplash = false + } + } } - Image(AppImages.SemiLion) - .resizable() - .aspectRatio(contentMode: .fit) - .frame(width: 200, height: 500) - } - - } - Spacer() - HStack { - Text("Copyright @") - .font(.headline) - .frame(alignment: .trailing) - - Text("Dou Shou Qi Team") - + } else { + TitlePageFrame(Text: "DOU SHOU QI", ImageWidth: 200, ImageHeight: 200) Spacer() - Text("2024") - .frame(alignment: .trailing) - } - .padding() // Ajout de padding pour éviter que le contenu ne touche la bordure - .background(Color.white) // Couleur de fond pour le HStack - .overlay( - Rectangle() - .stroke(Color.black, lineWidth: 1) // Couleur et épaisseur de la bordure - ) - - Spacer() - .onAppear { - MusicPlayer.shared.playBackgroundMusic(music: "TitleScreenMusic") + VStack { + HStack { + VStack(spacing: 25) { + MainMenuButton(text: "Play", destination: ScoreBoardView(), sound: "TitleScreenButtonSound") + MainMenuButton(text: "Historique", destination: HistoricView(), sound: "TitleScreenButtonSound") + MainMenuButton(text: "Best Scores", destination: ScoreBoardView(), sound: "TitleScreenButtonSound") + MainMenuButton(text: "Players", destination: PlayersView(), sound: "TitleScreenButtonSound") + } + Image(AppImages.SemiLion) + .resizable() + .aspectRatio(contentMode: .fit) + .frame(width: 200, height: 500) + } } - .onDisappear { - MusicPlayer.shared.stopBackgroundMusic() + Spacer() + HStack { + Text("Copyright @") + .font(.headline) + .frame(alignment: .trailing) + + Text("Dou Shou Qi Team") + + Spacer() + + Text("2024") + .frame(alignment: .trailing) } - + .padding() + .background(Color.white) + .overlay( + Rectangle() + .stroke(Color.black, lineWidth: 1) + ) + + Spacer() + .onAppear { + MusicPlayer.shared.playBackgroundMusic(music: "TitleScreenMusic") + } + .onDisappear { + MusicPlayer.shared.stopBackgroundMusic() + } + } } } } diff --git a/DouShouQi_App/DouShouQi_App/Views/Menu/SplashScreenView.swift b/DouShouQi_App/DouShouQi_App/Views/Menu/SplashScreenView.swift new file mode 100644 index 0000000..50919d1 --- /dev/null +++ b/DouShouQi_App/DouShouQi_App/Views/Menu/SplashScreenView.swift @@ -0,0 +1,23 @@ +// +// SplashScreenView.swift +// DouShouQi_App +// +// Created by étudiant on 27/05/2024. +// + +import SwiftUI + +struct SplashScreenView: View { + var body: some View { + TitlePageFrame(Text: "DOU SHOU QI", ImageWidth: 200, ImageHeight: 200) + .onAppear { + playSound(named: "SplashScreenSound") + } + } +} + +struct SplashScreenView_Previews: PreviewProvider { + static var previews: some View { + SplashScreenView() + } +}