Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
[ad_1]
You solely have a singular location
, so just one merchandise will ever seem in your instance. To have a number of gadgets, you may want some type of assortment, like an Array.
The next is a pared-down instance displaying utilizing an array:
struct Hammer: Identifiable {
var id = UUID()
var location: CGPoint
}
struct Level1: View {
@State var hammers: [Hammer] = [] //<-- Begin with `none`
var physique: some View {
ZStack {
ForEach(hammers) { hammer in // Show all the hammers
Picture(systemName: "hammer.fill")
.resizable()
.body(width: 30, top: 30)
.place(hammer.location)
}
}
.body(maxWidth: .infinity, maxHeight: .infinity)
.contentShape(Rectangle())
.gesture(DragGesture(minimumDistance: 0).onEnded { worth in
self.hammers.append(Hammer(location: worth.location)) // Add a Hammer
})
.edgesIgnoringSafeArea(.all)
}
}
Notice: I am unclear on what the GeometryReader
is for in your code — you declare it, then use UIScreen dimensions — usually in SwiftUI we simply use GeometryReader
[ad_2]