I started out by using my favorite graphics program to create a big You Lost graphic. When the player loses, a big You Lose message should appear, To inform the player about this horrible event. When the current number of lives reaches zero, our behavior triggers the no_more_lives event.
Now we don’t want our enemies to bump into the finish line – we merely want to detect when an enemy crosses the line. Using the “Add Box” button, add a box such that it is exactly as large as the finish line: Remove the default collision shape by selecting the default box and pressing the Delete button. Open the Finish Line actor and go to theĬollision tab. The first step is to determine the correct collision shape for our actor. Line? That’s where Stencyl’s built-in collision detection can help us. But how do we detect when an enemy crosses this Whenever an enemy crosses the finish line, it should cost one live. Using Pencyl, I created a nice black and white checkerboard pattern and added it to the scene. Let’s start by creating a Finish Line actor and put it in a new Collision Group called “Finish Line”. Now that we have lives, it is time to lose them. a hidden Boolean attribute “No More Lives Triggered?” – this will be used to ensure we will trigger theĪttach this behavior to the Test Scene, set the Number of Lives attribute to 10 and play-test your game.a hidden Actor attribute “Number of Lives Actor” – this will be used to keep track of the Heart icon.a hidden Number attribute “Current Number of Lives” – this will be used to keep track of the number of lives.a Number attribute “Number of Lives” – this will be used to configure the number of lives.The remaining number of lives reaches 0, it will trigger an event called “no_more_lives”. However, it will also make sure the remaining number of lives is never smaller than zero. The behavior will have a custom block “decrease number of lives by ” – this will decrease the remaining.
When the scene is redrawn, the behavior will draw the remaining number of lives next to the Heart.When the behavior is created, it will draw the Heart icon on the upper left screen.Now it is time to create a new Design Mode Scene Behavior called “Number of Lives Manager”. I also created an actor called “Number of Lives”, usedĪs its default animation and made it a member of the group “Visual Effects”. I started out by copying the Score Font to a new font called Lives Font and changed theĬolors to white and red. You will get better at it over time.īut first some preparations. Tip: there are no rules for choosing between Actor behaviors and Scene behaviors – use your gut feeling,Īnd don’t be afraid to change it later on. So, this time I will create our first custom Scene Behavior. However, the number of lives of the player is not related to a Until now, we have only created Actor Behaviors. The current number of lives has to be visible so the player knows how he’s doing. When the player has no more lives remaining, he has lost the game. Every time an enemy reaches the finish line, In order to be able to lose, I will keep track of the number of lives. StencylForge under the name “Publysher – TD Tutorial #9”. The result of this part can be seen here you can also find it on For now, winning will remain a promise :) In this part of the tutorial I’m going to work on losing Most games are about winning, and therefore about losing. Our Tower Defense game is slowly turning into a real game, but there is still a lot of work to do.