add animation

dev_views_Players
Rayhân HASSOU 1 year ago
parent 766b4683fc
commit b2b0298a7b

@ -31,7 +31,6 @@
649B59AE2BF64EAB002BAE38 /* AppImages.swift in Sources */ = {isa = PBXBuildFile; fileRef = 649B59AD2BF64EAB002BAE38 /* AppImages.swift */; };
649B59B22BF65392002BAE38 /* TextStyles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 649B59B12BF65392002BAE38 /* TextStyles.swift */; };
649B59B42BF653E1002BAE38 /* ViewTitleTextStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 649B59B32BF653E1002BAE38 /* ViewTitleTextStyle.swift */; };
EC62C4EF2BFE367F0048CD0B /* SwiftUIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C4EE2BFE367F0048CD0B /* SwiftUIView.swift */; };
EC62C4F92C0371660048CD0B /* MusicPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C4F82C0371660048CD0B /* MusicPlayer.swift */; };
EC62C4FB2C038BD20048CD0B /* PlayersView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C4FA2C038BD20048CD0B /* PlayersView.swift */; };
EC62C4FD2C0391D30048CD0B /* PlayerRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C4FC2C0391D30048CD0B /* PlayerRow.swift */; };
@ -104,7 +103,6 @@
649B59AD2BF64EAB002BAE38 /* AppImages.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppImages.swift; sourceTree = "<group>"; };
649B59B12BF65392002BAE38 /* TextStyles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextStyles.swift; sourceTree = "<group>"; };
649B59B32BF653E1002BAE38 /* ViewTitleTextStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewTitleTextStyle.swift; sourceTree = "<group>"; };
EC62C4EE2BFE367F0048CD0B /* SwiftUIView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUIView.swift; sourceTree = "<group>"; };
EC62C4F82C0371660048CD0B /* MusicPlayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicPlayer.swift; sourceTree = "<group>"; };
EC62C4FA2C038BD20048CD0B /* PlayersView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayersView.swift; sourceTree = "<group>"; };
EC62C4FC2C0391D30048CD0B /* PlayerRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerRow.swift; sourceTree = "<group>"; };
@ -156,7 +154,6 @@
isa = PBXGroup;
children = (
643AB69A2BFCFB5C0018DA73 /* HistoricView.swift */,
EC62C4EE2BFE367F0048CD0B /* SwiftUIView.swift */,
);
path = Game;
sourceTree = "<group>";
@ -498,7 +495,6 @@
649B59AE2BF64EAB002BAE38 /* AppImages.swift in Sources */,
649ABF602BF60F2D002E8894 /* MainMenuButton.swift in Sources */,
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 */,

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

@ -1,98 +0,0 @@
//
// SwiftUIView.swift
// DouShouQi_App
//
// Created by étudiant on 22/05/2024.
//
import SwiftUI
struct SwiftUIView: View {
var body: some View {
VStack {
TitlePageFrame(Text: "DOU SHOU QI", ImageWidth: 200, ImageHeight: 200)
Spacer()
VStack {
HStack{
VStack {
Button(action: {
// Action du bouton
}, label: {
Text("Play".uppercased())
.font(.headline)
.fontWeight(.semibold)
.foregroundColor(.white)
.frame(maxWidth: .infinity, maxHeight: 50)
.background(
Color.red
)
.cornerRadius(0)
})
.frame(width: UIScreen.main.bounds.width / 1.7)
.frame(maxWidth: .infinity, alignment: .leading)
Button(action: {
// Action du bouton
}, label: {
Text("Historique".uppercased())
.font(.headline)
.fontWeight(.semibold)
.foregroundColor(.white)
.frame(maxWidth: .infinity, maxHeight: 50)
.background(
Color.red
)
.cornerRadius(0)
})
.frame(width: UIScreen.main.bounds.width / 1.7)
.frame(maxWidth: .infinity, alignment: .leading)
Button(action: {
// Action du bouton
}, label: {
Text("Best scores".uppercased())
.font(.headline)
.fontWeight(.semibold)
.foregroundColor(.white)
.frame(maxWidth: .infinity, maxHeight: 50)
.background(
Color.red
)
.cornerRadius(0)
})
.frame(width: UIScreen.main.bounds.width / 1.7)
.frame(maxWidth: .infinity, alignment: .leading)
Button(action: {
// Action du bouton
}, label: {
Text("Players".uppercased())
.font(.headline)
.fontWeight(.semibold)
.foregroundColor(.white)
.frame(maxWidth: .infinity, maxHeight: 50)
.background(
Color.red
)
.cornerRadius(0)
})
.frame(width: UIScreen.main.bounds.width / 1.7)
.frame(maxWidth: .infinity, alignment: .leading)
}
.padding()
}
}
.padding(.horizontal, 10)
Spacer()
}
}
}
struct SwiftUIView_Previews: PreviewProvider {
static var previews: some View {
SwiftUIView()
}
}

@ -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 {
@ -37,10 +41,19 @@ struct MainMenuView: View {
MainMenuButton(text: "Best Scores", destination: ScoreBoardView(), sound: "TitleScreenButtonSound", topRightCorner: 10, bottomRightCorner: 10)
MainMenuButton(text: "Players", destination: PlayersView(), 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()
@ -65,15 +78,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