Make the player losing lives

Get help using Construct 2

Post » Sun Dec 09, 2012 8:05 pm

Hi, I have problems when I made my character lose lives when lose. At the moment when the player dies, I made the system resets all global variables (the game becomes very buggy if is not set) and subtracts 1 to the var "lives", but when system reset the Layout, lives keeps the same. I don't know how can fix it :(
B
5
Posts: 10
Reputation: 595

Post » Sun Dec 09, 2012 11:07 pm

can you please post a capx. this could be the result of numerous small things. some obvious some maybe not so much. so it would help to see what is happening.
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Sun Dec 09, 2012 11:20 pm

https://www.dropbox.com/s/45p9tdha2npkqxz/game.capx
B
5
Posts: 10
Reputation: 595

Post » Mon Dec 10, 2012 12:12 am

Jayderyu is likely a better expert to consult, but based on your initial message I'd double-check what's happening with the variables.

You said the game resets the variables, correct? Wouldn't that reset the 'lives' variable, as well? So the number would never change because it's being put back to the original number every time. It might be extremely difficult to manage a 'lives' number if you have to reset variables all the time.

You could use the WebStorage function to load/save the number of lives before doing the reset.
B
16
S
6
G
2
Posts: 152
Reputation: 3,764

Post » Mon Dec 10, 2012 3:17 am

I don't know why it doesn't work, using WebStorage makes the game start with 0 lives, even less numbers.
B
5
Posts: 10
Reputation: 595

Post » Mon Dec 10, 2012 7:40 am

Well ok. Here are a few things I found out towards working on your solution.

restart layout was resetting everything based around session storage. However, it did not reset Webstorage Local(ie long term). You might be able to get away with other methods by using another layout that has some vars or something, but I wanted to minimize any tampering to your own work.

https://dl.dropbox.com/u/14087254/HNK_game.capx


For now it uses local storage. Just remember when players do a fresh start to manually set the lives at the main menu before starting the game play.

Hope you find it of some use.

Thanks for the vote of confidence Space Ape, but I'm a noob at C2 :D. I just find the more I try to help the more I get my hands into quirks of C2 and become better at it over all :D





B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Mon Dec 10, 2012 5:01 pm

Jayderyu, maybe your adventurous spirit and battle experience shows through, then! :)

I'm finding the same thing by perusing the forums, reading about problems and how-to stuff; I keep asking "how would I do that?" and end up trying to work it out even if someone else is already helping.

In this case, I was thinking WebStorage local values would be an easier fix than trying to work around the reset thing.

Nicely done, sir.
B
16
S
6
G
2
Posts: 152
Reputation: 3,764


Return to How do I....?

Who is online

Users browsing this forum: YoHoho and 11 guests