pull/13/head
Rémi REGNAULT 11 months ago
commit 425a7fbea6

Binary file not shown.

@ -11,6 +11,12 @@ import SwiftUI
public struct AppImages {
static let TitleImage = "TitlePageImage"
static let SemiLion = "SemiLion"
static let SemiDog = "SemiDog"
static let SemiElephant = "SemiElephant"
static let SemiCat = "SemiCat"
static let SemiRat = "SemiRat"
static let SemiLeopard = "SemiLeopard"
static let SemiWolf = "SemiWolf"
static let Lion = "Lion"
static let Rat = "Rat"
static let Elephant = "Elephant"

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "SemiCat.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "SemiDog.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "SemiElephant.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "SemiLeopard.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "SemiRat.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "SemiTiger.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "SemiWolf.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

@ -41,6 +41,7 @@ struct PlayerRow: View {
.foregroundColor(.black)
}
Button(action: {
}) {
Image(systemName: "trash")

@ -10,6 +10,10 @@ import SwiftUI
struct MainMenuView: View {
@State private var showSplash = true
@State private var currentImage: String?
@State private var timer: Timer?
@State private var showImage = false
let images: [String] = [AppImages.SemiLion, AppImages.SemiDog, AppImages.SemiRat, AppImages.SemiWolf, AppImages.SemiLeopard, AppImages.SemiElephant, AppImages.SemiCat] // Add your image names here
var body: some View {
NavigationView {
@ -38,10 +42,19 @@ struct MainMenuView: View {
MainMenuButton(text: "Players", destination: PlayersView(), sound: "TitleScreenButtonSound", topRightCorner: 10, bottomRightCorner: 10)
MainMenuButton(text: "Settings", destination: SettingsView(), sound: "TitleScreenButtonSound", topRightCorner: 10, bottomRightCorner: 10)
}
Image(AppImages.SemiLion)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 200, height: 500)
if let currentImage = currentImage {
Image(currentImage)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 200, height: 500)
.transition(.opacity)
.animation(.easeInOut(duration: 1), value: showImage)
.onAppear {
withAnimation {
showImage = true
}
}
}
}
}
Spacer()
@ -66,15 +79,35 @@ struct MainMenuView: View {
Spacer()
.onAppear {
startTimer()
MusicPlayer.shared.playBackgroundMusic(music: "TitleScreenMusic")
}
.onDisappear {
stopTimer()
MusicPlayer.shared.stopBackgroundMusic()
}
}
}
}
}
private func startTimer() {
timer = Timer.scheduledTimer(withTimeInterval: 2.0, repeats: true) { _ in
changeImage()
}
changeImage() // Immediately change the image on appear
}
private func stopTimer() {
timer?.invalidate()
timer = nil
}
private func changeImage() {
DispatchQueue.main.async {
currentImage = images.randomElement()
}
}
}
struct MainMenuView_Previews: PreviewProvider {

Loading…
Cancel
Save