Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

How do i know that the tower attack twice?

In the video he explain how any why the code that was executed to kill the enemy. But the enemy had a life of 2 and the strength of the tower is 1. So therefore the tower had to attack twice, but i only see the code executed once. I know this isn't a exactly a coding question but should i automatically assume the tower attacked twice? Because it only show the code being executed once.

1 Answer

When coding in Playgrounds you see what´s going on with your code on the right side. For ex. When you Increase the life of the Enemy - the func fireAtEnemy should have a (2times),(3times), (4times) in brackets on the right side behind your enemy.decreaseHealth(self.strength), where the compiler returns whats going on. Thats how often the code was executed to get the Enemy´s life down to 0.