How do I keep the level bar from adding extra points?

TheMenOfHonorTheMenOfHonor Member Posts: 147
edited April 2012 in Working with GS (Mac)
Ok guys, this is an issue that appeared out of nowhere.

I have an app where you have a "level" bar because you can level up.

I have a button set to the following:

On release-if level=0 add 100pts

On release-if level=1 add 50pts

On release-if level=2 add 25pts




Then my level bar states:

If score > 100 then set bar score=0

This used to work juuuust dandy, until one day, out of nowhere it would
add the value of the next level, so now what happens is that once you
go from level 0 to 1, you gain 50pts automatically which is the value added IF you press
the button. Then when you go from level 1 to 2 the bar adds the value of the next level, 2.

So instead of going from 100 to 0, it goes from 100 to 0 + whatever amount the next level is
if you press the button.
I also have another bar that is smaller which works the exact same way, I copied and
pasted all of its commands and it works fine. it goes to zero after each level without any
extra pts.


Best Answer

Answers

  • TheMenOfHonorTheMenOfHonor Member Posts: 147
    I'm uploading it to you as a PM right now. Thank you for your help : )
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited April 2012
    In your practice points actor, you have rules for When touch is pressed/released and Level=0, Level=1, Level=2, etc. When you touch that actor and you're near the end of a level, it bumps you up to the next level and because you are still touching the actor for that instant, it triggers the next level condition and gives you some more points. In other words, you are touching the actor when the level has ended AND when the next level has begun.

    To resolve this, you need to give your level conditions a break so that they don't fire immediately when a new level starts. To do this, I added a game attribute called game.LevelUpDelay, a boolean. I added the condition that game.LevelUpDelay is false to the rule that checks if game.song1Level=0, =1, =2, etc. So instead of just When touch is pressed, it now says When ALL conditions are valid: touch is pressed and game.LevelUpDelay is false [check levels]. At the end of all of those level check conditions, I added change attribute game.LevelUpDelay to true and then a Timer that after 0.1 seconds (run to completion checked) change attribute game.LevelUpDelay to false. That seems to work. If it gives you any problems, just increase the Timer to 0.2 or longer to give your rules enough time to fire individually. It just means that the person using the app can't click practice points until 0.2 seconds has passed again.

    image

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.