Coin save data

0 favourites
  • 8 posts
From the Asset Store
Shamans coin has suitable for workers who work from home because it has player names that must be played alternately
  • Didn't think this would be so difficult..

    Each of my game's levels has coins you can collect. I want to save which coins are collected to a dictionary so they don't re-spawn when you die or load the game.

    I got it somewhat working by looping through the coins at the start and giving them an ID, saving the ID of the coins collected to a dictionary, then looping through the dictionary and destroying the coins with the same ID. It was something like that at least -w-;

    Problem is I've got a bunch of different levels so I have to factor that in, else Coin #1 you collected in 1-1 will also be destroyed in 1-2 and so on. I attempted this but it ended in a mess of loops and substrings and str/int conversion and so on. Ugh.

    Any ideas?

  • Hi ,

    I often use invisible sprites as spawn points, not sure if this is the method you are using?

    If it is, perhaps you could add an instance variable to each spawn sprite. Then once a particular coin has been collected, update the instance var for its corresponding spawn point and save it. When you come to respawn a level, only spawn coins at spawn points where instance var is = ?.

    Jeez, I've never used the word spawn so many times in a message ;)

    Anyway, not sure if this will help, but it's one way you could do it!

  • Bump

  • Couldn't you just give the coins a boolean variable collected. Set it to true when collected.

  • Thanks Whiteclaws

    I had to change it up a bit because I'm not using C2's layouts and UID's are constantly changing, but it really helped.

    Here are the final events:

    <img src="" border="0" />

  • Glad I helped !

    I'm really excited to see what you are cooking us :)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • use persist behavior to coins

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)