How do I save a character unlocked?

Get help using Construct 2

Post » Mon Dec 29, 2014 11:31 pm

Hi there, I've got another problem

So, I made a shop for my game for unlock characters, and with this solution is ok.

Shop.PNG

(Under the ShopButton to buy, there is a SetButton to select the character choosen)
(ShopButtons.Prezzo is a Instance Variable to make the price different for every button)

The problem is when I close the game, in fact, when I reopen it, I have to buy again all the characters unlocked previously. Is there a way to save the progress? I know that with the WebStorage I can save variables etc. but I don't know how to apply this method on more sprite all identical. (ShopButton)


Thanks in advance!
You do not have the required permissions to view the files attached to this post.
B
17
S
3
Posts: 62
Reputation: 1,054

Post » Tue Dec 30, 2014 5:27 pm

You must have the bought characters stored anywhere. It could be a server or a local Webstorage object, I don't know the requirements of your game so I can't tell which one you should choose. And, then, you must check them when you load the game.
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
20
S
6
G
3
Posts: 637
Reputation: 3,776

Post » Tue Dec 30, 2014 8:04 pm

Thanks, I know this method but I don't know how apply this method here.

This is my capx, if you want to look at it I'd be happy.
Feel free to change it if you want and give back to me correct

http://www.mediafire.com/download/nn9hn ... hop.caproj

The main problem is how to maintain the character unlocked after closing the game.

Thanks in advance!
B
17
S
3
Posts: 62
Reputation: 1,054

Post » Tue Dec 30, 2014 8:10 pm

Why don't you just use the persist behavior ? once destroyed it will never be come back
ImageImageImageImageImage
B
56
S
15
G
5
Posts: 852
Reputation: 11,446

Post » Tue Dec 30, 2014 8:28 pm

@Naji That's exactly the problem. The idea is to keep bought characters available between two sessions.

@Fiammaoscura Could not open the file. Save it as a single file (.capx) and send it again.
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
20
S
6
G
3
Posts: 637
Reputation: 3,776

Post » Tue Dec 30, 2014 8:40 pm

Sorry @brunopalermo this should work

http://www.mediafire.com/download/6wolu ... /Shop.capx
B
17
S
3
Posts: 62
Reputation: 1,054

Post » Tue Dec 30, 2014 9:28 pm

Here's an example:

shop-edited.capx


I edited a lot of stuff. Joined both buttons as different frames of the same button, added an array with information about the characters and the position of buttons, so you can add others, etc.

Let me know if that was what you were trying to achieve.
You do not have the required permissions to view the files attached to this post.
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
20
S
6
G
3
Posts: 637
Reputation: 3,776

Post » Tue Dec 30, 2014 10:33 pm

WOW! You're awesome! Thank you very very much!

One last little thing, one last question, if, as you said, I want to add other buttons, what should I modify? Only the JSON strings or even other things in the event sheet?

Thanks for your time and your patience!
B
17
S
3
Posts: 62
Reputation: 1,054

Post » Mon Jan 05, 2015 12:58 pm

Hi @Fiammaoscura,

Sorry for the delay... New years and stuff. :)

You just have to add a line in the JSON array to add a character. I made an example with 3 characters.

Also, I corrected an issue with the loop that creates the Webstorage objects, which was just creating 2, not as many as necessary. It does now.

Lastly, I added a Webstorage object to save the money. It is created the first time the player runs the game and is set to the value stored in STARTING_MONEY. And I added a text element to show us the amount of money the player has...

Here it is:

shop-edited.capx
You do not have the required permissions to view the files attached to this post.
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
20
S
6
G
3
Posts: 637
Reputation: 3,776

Post » Mon Jan 05, 2015 11:43 pm

Don't worry, you did a great job I'm grateful. Thank you very much!

You should write a tutorial, there isn't a tutorial to make a shop so detailed
B
17
S
3
Posts: 62
Reputation: 1,054

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests