How to keep high score on ALL scenes?
GoodnightMoon
Member Posts: 23
Last question of the day, I promise! haha
Okay, so my game is an endless runner game, whereby the higher my little space character travels, the more points the player gains. When the character hits an asteroid however, he then dies and a 'Game Over' window pops up (which is actually another scene) with the high score on it and a Play Again option.
However, my problem is that when my scenes are randomised - so that he's not flying through the same current of asteroids twice - the high score doesn't save on the Game Over scene, but just reverts back to zero?
Anyone have any ideas how to keep the high score on ALL scenes?
Many thanks in advance!
Comments
You should use a game attribute for the high score or, better yet, store the high score in a table.
Then, to display the high score where you want, just check the game attribute or the table cell value.
If you are storing the high score in an actor or some other volatile way like that, it will be lost when you reset scenes.
On another note, I know you are just starting out and learning your way around (which is great!), but --- it would be really beneficial for you to start thinking about ways to "reset" the scene without actually changing scenes.
When you change scenes, you force the player to wait while it loads which could get very annoying in most games (particularly endless runners where the player can die early and often).
To combat this, present the player with a RETRY button tied to a game attribute. When they press the retry button, set the game attribute to true (and be sure to set it back to false shortly after, so it functions like a switch). And then in each of your actors, create a rule that checks for when that retry game attribute is true. If true, do the necessary things to each actor that will essentially restart the game. (Like go back to their starting position, reset anything that was counting, etc.) This can be a lot of work, but the end result is a seamless experience for the user - well worth it!
Hi @Adrenaline, thank you for getting back to me! ^_^
I totally understand where you're coming from about resetting the scene as opposed to consistently changing scenes, which is hard on the program. But I feel that I'm too far gone with this game to change much (I'm on a deadline) but for my next project, I'll definitely be more prepared as I've learnt a lot already - and have only been at this for a week!
So, umm.. Seeing as I am pretty new to this, could you elaborate a bit more please on how I'd use the game attribute and check it etc in order to store the score?
Also, I used this guys YT tutorial to save my highscore, which worked great for me up until I had to start randomising scenes haha
No worries, I completely understand what you mean about the deadline and learning!
I just watched that video to see where you're at...it looks like it should work for you. You are doing the save and load attributes to store the high score, yes?
If you are, then the problem might be popping up if you have a behavior in one of your scenes that changes the high score unintentionally. Or maybe one of your scenes doesn't have a load and save attribute behaviors, and it's being overwritten somewhere along the lines.
If you're doing random scenes, make sure they all have the same load/save attributes concerning your high score so that value can be carried throughout your game.
Does any of that help at all?
Hi @Adrenaline ^_^
Okay, so I did it all again and put the save and load attributes in both scenes but it's still not working
Hmmm... This is most puzzling. The solution is probably dead easy but I just can't put my finger on it arghhh! >.<
Hmmm...sorry to hear that. Maybe you could attach a version of your project and someone else here could dive in to see what's going on. We have plenty of helpful people who do that regularly.
I'm at work right now with no access to GS...just stealing a few minutes here and there to browse the forums lol
Okay, thanks @Adrenaline!
Umm, if anyone could help me have my high score save across my scenes, I'd really appreciate it!
Also, apologises if my coding is a bit messy!
Thanks ^_^
Having taken a very brief look, I think you're trying to solve the wrong problem here. You're trying to fix the high score problem, but the extra scenes seem unnecessary. If you keep the game to one gameplay scene, the high score problem presumably goes away.
Feel free to drop me a message on Skype, this would be much easier with a good idea of what you're ultimately trying to achieve.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Agreed
Your High Score is actually saved between scenes, as you intend. The High Score functionality is working as you seem to intend. What you seem to be doing is on the "High Score" scene you're displaying game.Score, not game.High Score, under the text that says "High Score". There seems to be some confusion about what should be going on where.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Hi @Armelline,
Thank you for getting back to me ^_^
Umm, sorry but could you tell me where abouts exactly I should get changing game.Score to game.High Score? Do you mean the scene where I have the 'Game Over' window?
That really depends on what you're trying to do! It looks like you're wanting to display the high score on the "High Score" scene you use, so the "High Scoreee" actor's Display Text. But if you do that, you're not displaying the score they just got anywhere on the screen at the end of a game.
There seems to be some confusion over the high score/game score usage.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support