Basically I am just trying to find a way to tap a button and if "Player" collides with an object move to the next object and keep moving between those two objects. Another example of this would be if player collides with object A move to object B and if player collides with object B move to object A. (Continuously)
@IBAction func startBtn(_ sender: Any) {
if (player.frame.intersects(topLeft.frame)) {
UIView.animate(withDuration: 1, animations: {
self.player.center = self.bottomLeft.center
})
} else if (player.frame.intersects(bottomLeft.frame)) {
UIView.animate(withDuration: 1, animations: {
self.player.center = self.topLeft.center
})
}
}
Aucun commentaire:
Enregistrer un commentaire