Need help with adding all collected stars together!

Get help using Construct 2

Post » Sat Sep 03, 2016 3:53 am

Ops, my apologies, Aquanex2.

I missed your reply that said you couldn't open my files because they were version 234, because I've only read the latest reply. (Sorry..!!) :(

I have modified the files so that it can be opened in version 233 of Construct 2.

GMoney - star counter - v233.capx is the file from earlier today.
GMoney - star counter v2 - v233.capx is the file from my last reply.

https://www.dropbox.com/s/ea6xfm19bnx3e ... .capx?dl=0
https://www.dropbox.com/s/cfpftjjvpdywe ... .capx?dl=0

Please download the latest version of Construct 2 from the following page. :mrgreen:

https://www.scirra.com/construct2/releases
B
11
S
6
G
15
Posts: 256
Reputation: 9,207

Post » Sat Sep 03, 2016 4:54 am

Gmoney wrote:You mean like this one? :mrgreen:

https://www.dropbox.com/s/lepbb23odl7p9 ... .capx?dl=0

Game complete scenario

1. Added 2 more stars.
2. When all 5 stars are collected, the level clears.
3. Player is taken to the 'Complete' layout.
4. The message shows 'Collected all 5 stars! You have finished the first level..!! Click to reload the level..!!'
5. When clicked, the player is taken back to the first level with 0 total stars.

Game incomplete scenario

1. When player collects less than 5 stars and jumps into the goal, the player is shown a message that says 'Please collect all 5 stars. Restarting.'
2. The game restarts with 0 total stars.

I see what you did, but The object of my game is not to get the stars. It's just a simple platformer, and the stars are just extra. If you missed a star I wanted you to be able to replay the levels until you get them all, while showing you your total amount of stars on the level select.
B
24
S
9
Posts: 109
Reputation: 2,002

Post » Sat Sep 03, 2016 2:19 pm

I have added the following features.

1. Added a 'Level Select' button.

- When pressed, a Level Select screen will pop up to show how many stars are remaining.
- When discarded, the game will continue just the way you left it, right before entering the Level Select screen.

2. Added a feature to allow the Player who hasn't finished the level to restart without having to reset the number of stars remaining in game.

- Previously, when the Player reached the goal without collecting all the stars required to finish the level, the number status of the stars had automatically reset.
- What happens now is this. If the Player hasn't collected all the required stars, the Player will restart from the beginning of the level. The Player will notice only the remaining number of stars are in game and the ones s/he collected have disappeared.

By the way, I have downgraded my Construct 2 version to 233, because other people who I helped on the forum advised they were also using 233..

https://www.dropbox.com/s/1zwbn414ceh00 ... .capx?dl=0
B
11
S
6
G
15
Posts: 256
Reputation: 9,207

Post » Sat Sep 03, 2016 10:42 pm

Gmoney wrote:I have added the following features.

1. Added a 'Level Select' button.

- When pressed, a Level Select screen will pop up to show how many stars are remaining.
- When discarded, the game will continue just the way you left it, right before entering the Level Select screen.

2. Added a feature to allow the Player who hasn't finished the level to restart without having to reset the number of stars remaining in game.

- Previously, when the Player reached the goal without collecting all the stars required to finish the level, the number status of the stars had automatically reset.
- What happens now is this. If the Player hasn't collected all the required stars, the Player will restart from the beginning of the level. The Player will notice only the remaining number of stars are in game and the ones s/he collected have disappeared.

By the way, I have downgraded my Construct 2 version to 233, because other people who I helped on the forum advised they were also using 233..

https://www.dropbox.com/s/1zwbn414ceh00 ... .capx?dl=0


I want the Totalstars variable to add together all of the stars from all the levels. How would I do that while keeping the same code?
B
24
S
9
Posts: 109
Reputation: 2,002

Post » Sun Sep 04, 2016 1:11 am

1. Make a global variable Totalstarscollected = 0.
2. When Level 1 ends, add a system Event to add TotalStars variable's number to Totalstarscollected.
3. When Level 2 starts, reset TotalStars variable.
4. When Level 2 ends, add a system Event to add TotalStars variable's number to Totalstarscollected.
5. When level 3 starts, reset TotalStars variable and so on.
6. After all the levels are cleared, Player will be able to see how many stars were collected in total, by observing the Totalstarscollected variable.
B
11
S
6
G
15
Posts: 256
Reputation: 9,207

Post » Sun Sep 04, 2016 5:20 pm

Gmoney wrote:1. Make a global variable Totalstarscollected = 0.
2. When Level 1 ends, add a system Event to add TotalStars variable's number to Totalstarscollected.
3. When Level 2 starts, reset TotalStars variable.
4. When Level 2 ends, add a system Event to add TotalStars variable's number to Totalstarscollected.
5. When level 3 starts, reset TotalStars variable and so on.
6. After all the levels are cleared, Player will be able to see how many stars were collected in total, by observing the Totalstarscollected variable.


What if I want the player to be able to replay levels and get the same stars without adding stars that they already got?
B
24
S
9
Posts: 109
Reputation: 2,002

Post » Sun Sep 04, 2016 6:20 pm

The star status then must be stored via LocalStorage plug-in.

https://www.scirra.com/tutorials/1461/h ... age-plugin

The player won't need to play the levels played previously, nor need to collect all the stars again; even after closing the game and re-opening it later.
B
11
S
6
G
15
Posts: 256
Reputation: 9,207

Post » Sun Sep 04, 2016 7:03 pm

Gmoney wrote:The star status then must be stored via LocalStorage plug-in.

https://www.scirra.com/tutorials/1461/h ... age-plugin

The player won't need to play the levels played previously, nor need to collect all the stars again; even after closing the game and re-opening it later.


In my game, you play a level and get all the stars you find, then go to the goal. The level select shows you how many stars that you've gotten on each stage, so you know where you missed some. If I use localstorage, will I be able to make it so that any stars you get will be gotten, forever, even without using something like the persist behaviour?
B
24
S
9
Posts: 109
Reputation: 2,002

Post » Sun Sep 04, 2016 7:21 pm

Yes, because the Localstorage plugin will save data just the way how our usual save games are stored.

However, if the data is saved locally, they'll disappear once user deletes cache. (I'm not sure if cache is the correct term, but locally saved game files always disappear whenever we go to web browser's privacy section to remove cache and other details.)

That means the user will have to start from the beginning again, after the local files get wiped out.

If the game is going to be an epic scale, I would recommend you to store the data remotely on a server, so users can access their saved data no matter what happens to their local save files.

Setting up a remote save feature will need other things such as finding a good web hosting provider, setting up a database, handling configurations, etc.. though.

And that's a.. completely different beast. :cry:

https://www.scirra.com/tutorials/4839/c ... sql/page-1
local-storage-through-mobile-browser_t165787
B
11
S
6
G
15
Posts: 256
Reputation: 9,207

Post » Mon Sep 05, 2016 12:07 am

Gmoney wrote:Yes, because the Localstorage plugin will save data just the way how our usual save games are stored.

However, if the data is saved locally, they'll disappear once user deletes cache. (I'm not sure if cache is the correct term, but locally saved game files always disappear whenever we go to web browser's privacy section to remove cache and other details.)

That means the user will have to start from the beginning again, after the local files get wiped out.

If the game is going to be an epic scale, I would recommend you to store the data remotely on a server, so users can access their saved data no matter what happens to their local save files.

Setting up a remote save feature will need other things such as finding a good web hosting provider, setting up a database, handling configurations, etc.. though.

And that's a.. completely different beast. :cry:

https://www.scirra.com/tutorials/4839/c ... sql/page-1
local-storage-through-mobile-browser_t165787


I think I've finally figured out what I need to do!

Thanks, Gmoney! You've been a big help!!! I am eternally grateful! :mrgreen: :mrgreen: :mrgreen:
B
24
S
9
Posts: 109
Reputation: 2,002

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 5 guests