buttons help please?

linemaniac231linemaniac231 Member Posts: 7
edited November -1 in Working with GS (Mac)
In a game I am making, you destroy all the enemies in each level to move on. Does anyone know a way to make a button pop up ONLY after you have destroyed each enemy?

Comments

  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Create a game(global) attribute for total number of enemies. When you destroy an enemy, decrement the game attribute. Then have a rule that checks if that attribute == 0, then spawn actor your button.
  • linemaniac231linemaniac231 Member Posts: 7
    I still dont really understand, how do I make it decrement the game attribute?
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Change Attribute behavior. x <= x -1
    where x is your game attribute selected through the expression editor and attribute browser.
  • linemaniac231linemaniac231 Member Posts: 7
    I tried all this, but it still wont work. :(
  • Nubc4kesNubc4kes Member Posts: 4
    So, if this extensive walkthough comes off as condescending, that was not the intent. I don't know what part is tripping you up, so I just a wall-o-text that will hopefully cover all the bases.

    In you game attributes you want to make a new one call it, for intents and purposes, call it "Enemy count".

    Make that equal to the number of enemies you want the player to kill.

    Next, go back to the "Actors" panel and open up the actor that's your enemy.

    Inside of his behaviors, hopefully you have some condition for when the enemy is destroyed. (i.e. collides with bullet or whatever) Inside of that Rule block, place a "Change Attribute" behavior before the "Destroy" behavior.

    On the Change Attribute box you added, click on the "..." next to it. In the first panel of that window that pops up, click on "Game", the double click "Enemy Count".

    In the next box, click the e (which is called the "Expression Editor"). In the window that pops up, click the blue arrow next to he check mark. Click on "Game" then "Enemy Count". Now click by the blue oval saying "game.Enemy Count". Type "-1". Click the green check mark.

    Now inside of another actor, create a rule that states "An attribute changes game.Enemy Count is equal to 0". Inside of that put a "Spawn Actor" behavior. Make it spawn the button at 240, 180 relative to scene (that way it's in the middle of the screen).

    Hope that helps.
  • linemaniac231linemaniac231 Member Posts: 7
    okay, Ive been able to get most of it working, but I have one more problem with it. I set the "change attribute" behavior to only take away one enemy per kill, but when I kill one, sometimes it will take away three or sometimes it will take away five, etc. etc. How do I fix this?
Sign In or Register to comment.