I have a simple animation with a UIImage(a small red dot) moving across the screen using the animation with duration function. There is also a button. When the button is pressed the program should get the coordinates of where the UIImage is at that moment. I've tried to use the following code to get the coordinates but they only seem to get the starting location and the ending location.
@IBAction func button(sender: AnyObject) {
let dot = Int(redDot.center.y)
print(dot)
}
With the code above no matter when you click the button you will get the starting location of the dot, unless the animation is finished. Then it will print the ending location.
Any help is appreciated.
Code for animation
func GameLoop(){
UIView.animateWithDuration(GLOBAL_ANIMATION_TIME, animations: {
//Animates Dot
self.redDot.center.y = -25
}) { (true) in
//Resets dot when animation is complete
self.redDot.center.y = UIScreen.mainScreen().bounds.height + 25
}
}