How to update my own in-game leader board
Hi Guys and Gals, I'm having a bit of a problem so I hope ye can help me? I'll try and explain this as best I can, I have my own leaderboards added to my game (not gamecenter) and the way it works is I have five attributes game.timer, game.level1timer, game.level2timer, game.level3timer and game.level4timer I have game.timer on a timer that says every 1 second change game.timer to game.timer+1 and on my leaderboard screen I want it to display game.level1timer in one box and game.level2timer in the next box etc etc..
So what I really need to know is how do I get it to save game.timer to game.level1timer for the first level then reset back to zero then record game.timer to game.level2timer for the second level, then once that is done how would I get it to only save game.level1timer if it is less then game.level1timer i.e if the player replays level one and gets a better time I would only like it to save if its a lesser time than the first time the player completed the level and then show on the leaderboard scene.
I hope I explained myself enough but if ye need to ask me any questions just ask and I'll try and explain myself a bit better. I'm at a total standstill with my next project until I can figure this out so I really hope you guys can help me out, Thanks for reading
So what I really need to know is how do I get it to save game.timer to game.level1timer for the first level then reset back to zero then record game.timer to game.level2timer for the second level, then once that is done how would I get it to only save game.level1timer if it is less then game.level1timer i.e if the player replays level one and gets a better time I would only like it to save if its a lesser time than the first time the player completed the level and then show on the leaderboard scene.
I hope I explained myself enough but if ye need to ask me any questions just ask and I'll try and explain myself a bit better. I'm at a total standstill with my next project until I can figure this out so I really hope you guys can help me out, Thanks for reading
Comments
for ordering a list of those attribute values: you will need attributes to hold listTimePlacements (real) and levelNames (text)… then
Rules: when (All) … (name this rule: ? level 1 1st place ?)
Attribute: game.level1Time < game.level2Time
Attribute: game.level1Time < game.level3Time
Attribute: game.level1Time < game.level4Time
--changeAttribute: game.list1st To: game.level1Time
--changeAttribute: game.list1stName To: Level 1
Otherwise:
Rules: when (All)… (name this rule: ? level 1 4th place ?)
Attribute: game.level1Time > game.level2Time
Attribute: game.level1Time > game.level3Time
Attribute: game.level1Time > game.level4Time
--changeAttribute: game.list4th To: game.level1Time
--changeAttribute: game.list4thtName To: Level 1
then create rules for 2nd and 3rd place
do for each level
sounds complicated … this is a lot of rules … but mostly option+drag after the 1st set and just select the correct attribute
you may want a controlActor running this and mayhap have your background spawn that control after the scene loads
Good Luck!
@};- MH
I got it to display the game.level1timer so I have managed to change my game.timer to game.level1timer and then save it but now it only saves if the player takes longer to complete the level i.e player 1 completes it in 10 seconds but if player 2 completes it in under 10 seconds it doesn't update or save, but if player 3 does it in 12 seconds it updates and saves no problem.
Oh my head hurts right now and things are getting very messy :O
Create one game.timer where you run the normal timer count up.
Then when level ends in success check timer agains best time if you have one. else create one so you have a current timer and a best time.
However the first score is always 0 since there's no best time yet so have the rule
If best time = 0 or best time > game.timer
change attribute best time to game.timer
save attribute best time to l1best or whatever naming convention you wish.
Then set the game.timer back to 0 for next level.
So every time you win that level save attribute for the best time accordingly l1best, l2best whatever you named it.
Then on your own leader board page use the load attribute rule to display all the individuals best time on each level's boxes.
That's how it can be done.
Here is a screenshot maybe you could tell me if you see anything wrong, just don't laugh because I have a feeling I'm doing something very wrong but very simple to fix :-S
It's a bit confusing when you are using the same naming for game attribute and save keys...
so the saving part is basically,
when level completes is true
check if best time = 0 or best time more then current time
change best time to current time
save attribute current time
This is how I am saving everything and when the level is finished a menu pops up and when you click next level it resets game.LBTimer back to 0
This is how I am loading the best time attribute for each of the levels but where it says T.S1.L1 for the key for level 1, on level 2 I use T.S1.L2
This is my leader board screen just to show you how everything looks
Thanks again you have been a great help so far
Example level1 box should be load attribute T.s1.l1 to self.besttime(level1 box)
then use your display rule with self.besttime instead. For every other level boxes use the same way. for level2 load attribute t.s1.l2 to self.besttime(level2 box)
then use the display rule etc....