Coins

Hey, I was just wondering if it's possible to save the coins you have collected in a game. For example let's say you have 3 lives, and in your first life you collect 3/5 coins but then die. When you respond how do you make it so those coins that you collected don't re spawn? I figured out the whole coin count system, I just don't know how to make it so those coins don't reappear.

Comments

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273

    You need to save the coin count in a game (global) attribute. These attributes won't be changed when your player dies, so you can use the attribute (variable) to keep track of the number of coins the player collected.

  • AadeeAadee Member Posts: 24

    @Braydon_SFX said:
    You need to save the coin count in a game (global) attribute. These attributes won't be changed when your player dies, so you can use the attribute (variable) to keep track of the number of coins the player collected.

    I'm still a little confused...could you show me an example or something?

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273

    @Aadee said:

    @Braydon_SFX said:
    You need to save the coin count in a game (global) attribute. These attributes won't be changed when your player dies, so you can use the attribute (variable) to keep track of the number of coins the player collected.

    I'm still a little confused...could you show me an example or something?

    Maybe this will help introduce you to attributes in GameSalad.

    Essentially, you need to create an integer game attribute called 'coinsCollected' (or whatever you want), and increment that attribute every time the player collects a coin. This way you're keeping track of the coins the player collected.

  • AadeeAadee Member Posts: 24
    edited April 2020

    @Braydon_SFX said:

    @Aadee said:

    @Braydon_SFX said:
    You need to save the coin count in a game (global) attribute. These attributes won't be changed when your player dies, so you can use the attribute (variable) to keep track of the number of coins the player collected.

    I'm still a little confused...could you show me an example or something?

    Maybe this will help introduce you to attributes in GameSalad.

    Essentially, you need to create an integer game attribute called 'coinsCollected' (or whatever you want), and increment that attribute every time the player collects a coin. This way you're keeping track of the coins the player collected.

    Thanks a lot, but I understand attributes, I just don't understand how I should save my coins. What do I need to do to make them save? A table or something?

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273

    You could put them in a table, or use the 'Save Attribute' behavior.

  • AadeeAadee Member Posts: 24

    @Braydon_SFX said:
    You could put them in a table, or use the 'Save Attribute' behavior.

    How do you insist I do that?

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273

    @Aadee said:

    @Braydon_SFX said:
    You could put them in a table, or use the 'Save Attribute' behavior.

    How do you insist I do that?

    If you google tutorials on Youtube, there are various videos that can help you how to use these behaviors. :)

  • AadeeAadee Member Posts: 24

    @Braydon_SFX said:

    @Aadee said:

    @Braydon_SFX said:
    You could put them in a table, or use the 'Save Attribute' behavior.

    How do you insist I do that?

    If you google tutorials on Youtube, there are various videos that can help you how to use these behaviors. :)

    Hey, ya I already have and I still am not able to find what I am looking for. I don't know if I a'm looking in the wrong place. Please help! Thanks!

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273

    @Aadee said:

    @Braydon_SFX said:

    @Aadee said:

    @Braydon_SFX said:
    You could put them in a table, or use the 'Save Attribute' behavior.

    How do you insist I do that?

    If you google tutorials on Youtube, there are various videos that can help you how to use these behaviors. :)

    Hey, ya I already have and I still am not able to find what I am looking for. I don't know if I a'm looking in the wrong place. Please help! Thanks!

    Not sure how else to help you without seeing your logic. :) Can you post a screenshot?

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    Not sure if this is what you're looking for but a demo of one way to accomplish this using a table is attached. I don't have the player dying but instead moving between 2 scenes. Move the white square around with the arrow keys, when you pick up a coin it will record in the table that it's been picked up by writing a 1 into the correct row of the table. Go to the green 'door' to go to scene 2, pick up a coin and use the green door to go back to scene 1. Leave some coins on each scene so you can see that the ones you've already picked up don't show the second time you enter the scene.

    Each coin has an Attribute called 'myId' that keeps track of its row in the table. Each coin checks the table when the scene is loaded and if there is a 1 in the table the coin deletes itself so it's no longer in the scene. When the player picks up a coin it writes a 1 into its row in the table so it knows not to show next time the scene loads.

    Hope this helps.

  • AadeeAadee Member Posts: 24

    @jamie_c said:
    Not sure if this is what you're looking for but a demo of one way to accomplish this using a table is attached. I don't have the player dying but instead moving between 2 scenes. Move the white square around with the arrow keys, when you pick up a coin it will record in the table that it's been picked up by writing a 1 into the correct row of the table. Go to the green 'door' to go to scene 2, pick up a coin and use the green door to go back to scene 1. Leave some coins on each scene so you can see that the ones you've already picked up don't show the second time you enter the scene.

    Each coin has an Attribute called 'myId' that keeps track of its row in the table. Each coin checks the table when the scene is loaded and if there is a 1 in the table the coin deletes itself so it's no longer in the scene. When the player picks up a coin it writes a 1 into its row in the table so it knows not to show next time the scene loads.

    Hope this helps.

    This did very much! Thank you so much!!!

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
Sign In or Register to comment.