Do something only once within a range?

Get help using Construct 2

Post » Wed Jun 01, 2016 11:02 pm

I have a score, and if the player receives a 3 or 4 score (from racing laps), they get a small trophy; 5 , 6 or 7, they get a medium trophy, 8 or 9, a big trophy and 10+ a big trophy. I'm testing if a LocalStorage value is smaller than a lap, and if the value written in LocalStorage is lower than the lap, the trophy is shown. This works well, since if the player is replaying a level and they receive a lower score, it still retrieves and shows their highest won trophy ever for the level. When the get a higher lap than is saved in LocalStorage, it writes the higher score to localstorage and shows the new, bigger trophy. I also have a failsafe wheby is the the LocalStorage key doesn't exist, it writes the current lap to it regardless.

Now, the problem is, I can't think of how to play a "tadah" sound the FIRST time the player wins the trophy. It has a tendency whatever I write to play the "tadah" sound upon retrieving the score from LocalStorage and displaying the trophy that has been won in the past. Any clue what kind of LapCount/LocalStorageValue test I would have to perform to make sure the "tadah" sound only plays the first time the play wins the trophy?
B
41
S
12
G
14
Posts: 1,122
Reputation: 11,268

Post » Wed Jun 01, 2016 11:08 pm

If you would store also the "trophy size" to every level it should be solved.
If trophy is bigger than the stored one = Tada

Edit: you also could look at the stored score/time/lap because you know which trophy he has and so you could also check.... (but my first suggestion is simpler)

  • System > On start of layout | system > load game from slot "brain"
  • System > On load failed | system > scroll to obj_Forum
B
17
S
8
G
5
Posts: 340
Reputation: 4,707

Post » Thu Jun 02, 2016 7:07 am

fm4fanAT wrote:If you would store also the "trophy size" to every level it should be solved.
If trophy is bigger than the stored one = Tada

Edit: you also could look at the stored score/time/lap because you know which trophy he has and so you could also check.... (but my first suggestion is simpler)


Thanks, I actually tried that first method after I posted this but it also didn't work, I think I might need to try again and make sure the lap numbers are being reported properly...
B
41
S
12
G
14
Posts: 1,122
Reputation: 11,268

Post » Thu Jun 02, 2016 11:47 am

GameEnded
curent score >localstorage highscore
    set localstorage highscore to score
    trigger once
    Audio play tadah.


that should work hope it helps you.
B
78
S
23
G
69
Posts: 1,353
Reputation: 44,005

Post » Thu Jun 02, 2016 11:53 am

Thanks, @gamecorpstudio I'm already doing some of that, I managed to work it be getting the LocalStorage checks in the right order, thanks @fm4fanAT for reassuring me it would work!
B
41
S
12
G
14
Posts: 1,122
Reputation: 11,268


Return to How do I....?

Who is online

Users browsing this forum: DiegoSanudoDT, R0J0hound and 13 guests