playMaker

Author Topic: End of level stars  (Read 1898 times)

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
End of level stars
« on: December 16, 2014, 06:11:54 PM »
I try to figure out how I can store the stars I receive when I finish the level. If I receive 1 or 2 stars, and then I try the level again and get 3 stars, it will store 3 stars in the level menu, but if I get 1 star when I already have 2 or 3 stars, it will store 1 star. And that's my problem. I only want it to store the stars when I get more stars.

I have almost got it to work, but it register also when I get 1 or 2 stars when I already have 3.

After I tried and tried and tried with different things, I give up. I can't stand it anymore. I need to stop before I do something I will regret.

I have a Global Variable I store the stars. If I finish the level in 30 sec. I get 3 stars, so then I set this Global Variable to 3. And 40 sec. to 2 and 50 sec. to 1 star.

In the level menu, I use in the first state. I have PlayerPrefs Get Int. Next state I have an Int Compare where compare the Global Variable to the Local Variable. And then I use an Int Switch to check if I get 1, 2 or 3 stars. And then I have 3 new states. I named them. 1 Star, 2 Stars and 3 Stars. And in these states, I use a Set Int Value where I set in the Int Variable, the Local Variable and in the Int Value, the Global Variable.

I got it to work on one level. When I get 1 star on level 1, it stores it. Next time I get 3. And then it stores 3 stars. Next time I get 2 stars. And it still 3 stars. So this is working, but when I then go to level 2 and get 1 star. It register it also on level 1 and 2.

Can somebody help me through this? Or make an example how to stores things through levels? I was thinking maybe Easy Save 2 can work.

But anyway, please help me! I give up now. At least for today. I'm tired of this.
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: End of level stars
« Reply #1 on: December 19, 2014, 08:12:43 PM »
did you give a different name for level 2

and are your global names different than the PlayerPrefs names?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: End of level stars
« Reply #2 on: December 19, 2014, 09:26:40 PM »
at the end of your level you should compare your "Current_stars"

get the stars int, that are saved in PlayerPrefs
then do int compare.
if Current_stars is greater than the stars in PlayerPrefs,
save Current_stars to PlayerPrefs.

in level menu only get the PlayerPrefs info to display stars on your levels

hope you understand, i don't have time atm to make a sample.
if not, let me know i will make a sample tomorrow.

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: End of level stars
« Reply #3 on: December 21, 2014, 05:26:23 AM »
Hi!
Level 2 has a different name. And I have a different name on the Global name and the PlayerPrefs name.

I haven't had time to look at it now, but if you could make me an working example, I would be very happy. My brain was almost boiled when I tried to figure out this. :)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no