Type of Counter
KempProductions
Member Posts: 139
Ok, im trying to create a game where you have to destroy a certain number of blocks, without letting an item at the top of the stacked blocks, hit the ground. I've figured a lot of it out, but I don't know how to add a counter to keep up with how many blocks you have left to destroy. Can anyone help me??
Comments
You need a game.attribute named 'Blocks Left'
Under the rule that 'destroys' the block add a Change Attribute:
game.Blocks Left = game.Blocks Left -1
You need to keep a global game attribute (integer) called "blockCount". When the level starts, set it to the appropriate amount.
Every time you remove a block, use a Change Attribute behavior to set it like this:
Change Attribute:
game.blockCount To: game.blockCount -1
Hope this helps!
Joe
Touch is Pressed
Destroy this actor
Change Attributee counter-1
Then when attribute counter less than or equal to 0
Cheers, Weswog
EDIT:Sorry I was writing on this post and FMG Wrote before me
Crazy how we all compete to be first to answer the easy ones
-I figured out how to display text such as "congrats" when the 'blockcounter' equals 0 and the item has not touched the ground. And i was able to figure out how to reset the level when the item touches the ground. But i cant figure out how to display text in the middle of the screen that says something like "sorry, or fail" when this happens, and how to reset the 'blockcounter' to its orginal value when the scene resets.
Then in the text actor have a rule that says when game.lose is true display text "better luck next time!"
Change game.blockcounter to 0 (or whatever the starting point should be)
This is how I like to do it. I do this to reset my HP when you lose.
When HP = 0 Spawn actor "Mission Failed"
The "Mission Failed" actor is a graphic file that says "Mission Failed".
In that actor I have
Timer: After 2 secs change game.HP to 20. (check completion box)
Timer: After 3 secs change scene. (check completion box)
Hope this helps.
Then, I realized, that due to the 'blockCounter' being a Game Attribute, the number has to be the same throughout the game. Which is not what I would like. If there is a way to change this number throughout the game, please tell me. Otherwise, I wont be able to make my game.
Now you could just add a controller object that sets the blockCounter attribute for each specific scene.