Last active
April 22, 2022 08:41
-
-
Save EricGustin/fefcc8583d719a9e282b02b8865badfb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @objc func hitEnemy() { | |
| updateHealthBar() | |
| UIView.animate(withDuration: 0.25, animations: { | |
| self.enemy.transform = CGAffineTransform(scaleX: 0.8, y: 0.8) // Scale the enemy down to 0.8 of its size over 1/4 of a second | |
| }) { _ in | |
| UIView.animate(withDuration: 0.25) { | |
| self.enemy.transform = .identity // Once the enemy is done scaling down in size, have it return to its original size over a period of 1/4 of a second | |
| } | |
| } | |
| } | |
| private func updateHealthBar() { | |
| UIView.animate(withDuration: 0.5) { | |
| self.healthBar.setProgress(self.healthBar.progress - 0.25, animated: true) // Take away a fourth of the enemy's health over a period of 1/2 of a second | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment