Hi,
I can’t seem to make the slots display appear on the app. Here’s a screenshot and the whole code pasted. Any advice?
Thank you!
//
// ContentView.swift
// L13 APP
//
// Created by Ellie on 2/9/23.
//
import SwiftUI
struct ContentView: View {
@State var slot1 = 1
@State var slot2 = 1
@State var slot3 = 1
@State var credits = 1000
var body: some View {
VStack(spacing: 20.0) {
Spacer()
Text("SwiftUI Slots!").font(.largeTitle)
Spacer()
Text("Credits \(credits)")
HStack {
Image("star\(slot1)")
.resizable()
.aspectRatio(contentMode: .fit)
Image("cherry\(slot2)")
.resizable()
.aspectRatio(contentMode: .fit)
Image("apple\(slot3)")
.resizable()
.aspectRatio(contentMode: .fit)
}
Spacer()
Button("Spin") {
slot1 = Int.random(in: 1...3)
slot2 = Int.random(in: 1...3)
slot3 = Int.random(in: 1...3)
if slot1 == slot2 && slot2 == slot3 {
credits += 15
}
else {
credits -= 5
}
}
.padding()
.padding([.leading, .trailing], 40)
.foregroundColor(.white)
.background(Color(.systemPink))
.cornerRadius(25)
.font(.system(size: 18, weight: .bold, design: .default))
Spacer()
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}