Book Image

Gamesalad Essentials

By : Miguel DeQuadros
Book Image

Gamesalad Essentials

By: Miguel DeQuadros

Overview of this book

Table of Contents (16 chapters)

Ammo


While we could let Kevin have an unlimited amount of ammo, what kind of challenge would that be? Ammo is another easy thing to program into GameSalad. We will start by creating a game-wide attribute, which will be an Integer, and we will call it Ammo, change the Value to 500. Alternatively, you could set it to a low number such as 7, and create another attribute for the amount of clips; then once you run out of ammo, decrease the number of clips and reload the ammo. However you want to do it, I'm going to show you how to do it! In our Kevin actor, create a new rule, change it to Attribute | game.GunCollected | is | true, and then drag in a Display Text behavior. For the text click on the e button to open up the expression editor and select game.Ammo, and set the Y position to 40, and the Size to 10. Once you collect the gun, it will display the ammo value above Kevin's head. Handy!

To count ammo that is being depleted, go into our Inter-Dimensional Gravity Distributor actor. That didn...