I want to move an object on the screen, making it harder for the user to click on.
The object will appear for a few seconds and if clicked it will provide user an advantage in the game.
I wouldn't want it to appear in one spot then a second later appear on another spot. I'd love it to slide from place to another.
My example code is below:
struct level1: View { @State var makeIt10xPressed = false @State var showWin10x = false var timeTimer : Timer { Timer.scheduledTimer(withTimeInterval: 5, repeats: true) { _ in print("timer") self.showWin10x = true DispatchQueue.main.asyncAfter(deadline: .now() + 3) { self.showWin10x = false } } } func makeIt10x () { if makeIt10xPressed == true { print("10x more point") } } func win10x () { self.makeIt10xPressed = true DispatchQueue.main.asyncAfter(deadline: .now() + 10) { self.makeIt10xPressed = false } } var body: some View { GeometryReader { geometryProxy in ZStack { Image("mine1") .resizable() .frame(width: UIScreen.main.bounds.height * 1.4, height: UIScreen.main.bounds.height) .gesture(DragGesture(minimumDistance: 0).onEnded { value in print("get one point") }) if self.showWin10x { Button(action: { self.win10x() }) { Image("bat").resizable.frame(width: UIScreen.main.bounds.height * 0.10 , height: UIScreen.main.bounds.height * 0.10) } } } }.edgesIgnoringSafeArea(.all).onAppear() { _ = self.timeTimer } } } I want the Image("bat") to move around the screen. Thanks.
