Save Issue

Just started using Construct 2? Post your questions here

Post » Thu Sep 25, 2014 10:59 pm

I am trying to understand the logic behind Webstorage. I want to use it to save my game on an android device.

Basically I have a global score, that I set it to text, then I make the text show up on a category page.. So if there are 10 levels in the game, I want to show you the score you received on each level played. I am having no luck. I saw a lot of save tutorials, but its does not seem to be working for me. Can someone help me out pls. thx
B
9
S
2
Posts: 104
Reputation: 1,098

Post » Tue Sep 30, 2014 2:22 pm

The logic will generally look something like this, just to make sure that you've got it down right:

1) Player completes level X and sets a score, let's call it a global variable LevelScore.
2) Compare score to currently saved high score (compare as a number), called WSLevelXScore or whatever.
3) If the current score is higher, set WSLevelXScore to LevelScore.
4) Then you set your text objects on the level select screen.

The last bit is tricky, because it requires that you set each text object individually. You could create ten different text objects, but its much easier to create one and clone it nine times. Each time you clone it, you're adding 1 to its IID (instance ID, starting from 0). So to set the scores to each of them, do something like this:

System : On Start of Layout, Repeat 10 times, Pick nth instance (ScoreText)(loopindex) -> Set ScoreText Text to WebStorage.LocalValue("WSLevel"&loopindex+1&"LevelScore").

I've attached a quick example of the last bit.
You do not have the required permissions to view the files attached to this post.
B
57
S
15
G
11
Posts: 912
Reputation: 12,626

Post » Tue Oct 07, 2014 2:07 pm

Thanks @GeometriX
B
9
S
2
Posts: 104
Reputation: 1,098

Post » Sun Dec 07, 2014 6:18 pm

Save for mobile is kinda easy. SAVE on the layout you want, then use the LOAD on the layout the player will open the app to. Hit me if this confusing.
B
9
S
2
Posts: 104
Reputation: 1,098


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests