Create a score that doesn't reset on new layout

Get help using Construct 2

Post » Mon Jul 08, 2013 1:00 pm

Hello!

I'm figuring out Construct 2 and really like it and bought the license. Now I'm practicing with a platform demo.

I created a score on the platform but when I'm going to the next layout it sets to zero. I tried multiple things and I don't understand why it resets. Also tried using webstorage but I don't seem to figure it out yet.

I read multiple tutorials and searched the net for the problem but still can't find a solution.

Uploaded my capx as rar here http://surreal3d.nl/capx/platformdemo.rar
Hope you can help :)

Sander
B
8
S
2
Posts: 12
Reputation: 663

Post » Mon Jul 08, 2013 1:30 pm

Hi @Surrealizer,

Welcome to C2, glad you're enjoying it so far!

I just took a look at your capx, and you are using local variables for score, health etc. It would be better to use global variable, as these can be used anywhere even across different layouts.

To add a global variable just right click on the event sheet, then scroll down to 'add global variable'. And don't forget to change your code, so that you're adding score, health etc, to your new global variables.

Hope that helps :)Blacksmith2013-07-08 13:31:22
B
34
S
6
G
7
Posts: 494
Reputation: 8,282

Post » Mon Jul 08, 2013 1:52 pm

Hi @Blacksmith

Thanks for your reply! I guess you're right, I thought I already had global variables because global was set on yes on the left.

I changed it like you said and it's fixed! Thank you so much for your help!
B
8
S
2
Posts: 12
Reputation: 663

Post » Mon Jul 08, 2013 2:46 pm

Hey @Surrealizer,

No problem, glad I could help. And don't worry, it does take a little while to get used to a new environment, and a new way of doing stuff. Keep at it, and you'll be an old-pro in no time ;)Blacksmith2013-07-08 14:47:07
B
34
S
6
G
7
Posts: 494
Reputation: 8,282

Post » Wed Jul 10, 2013 1:16 pm

@Blacksmith

Didn't want to start another topic so maybe you know the solution? I got a ground enemy which I want to have health. I used a local (health) variable. It's working but because of a wait function (so you can see a dying animation before it's destroyed) the (global) kill score adds like 12 points instead of 1. I don't understand why this happens because it doesn't happen to enemies without health (with wait function).

http://surreal3d.nl/capx/platform_groundenemy.rar
http://surreal3d.nl/capx/platform_groundenemy.capx
B
8
S
2
Posts: 12
Reputation: 663

Post » Wed Jul 10, 2013 1:41 pm

It is because of the wait action.
During the time that it is waiting, the condition is still true and the actions are still being registered (as explained in this tutorial).

Make a new event Enemy: On destroyed and have your action "Add 1 to kill" in it. This way, the addition will only happen once, and only once the object is actually getting destroyed.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
296
S
119
G
96
Posts: 7,332
Reputation: 71,306

Post » Wed Jul 10, 2013 1:51 pm

@Kyatric

Thank you very much the problem is solved.

I thought it would be something like that but somehow it didn't happen to the enemy without health.   

Thanks for the info I will check out the tutorial!
B
8
S
2
Posts: 12
Reputation: 663

Post » Wed Jul 10, 2013 2:09 pm

Hey @Surrealizer,

Ah, I've just been testing your example and putting together a reply, but I guess it's not needed now!

Glad you found an answer though (thanks @Kyatric).

Good luck with the rest of your project :)
B
34
S
6
G
7
Posts: 494
Reputation: 8,282

Post » Wed Jul 10, 2013 2:21 pm

Hey @Blacksmith

Yes it's solved. Thanks for your time and effort!

I will it's great working with construct. Always want to figure things out myself but when I can't understand the logic of something not working I have to ask after a couple of hours/days...

I'm amazed how helpful this forum/community is
B
8
S
2
Posts: 12
Reputation: 663

Post » Wed Jul 10, 2013 2:44 pm

@Surrealizer,

Yeah, the C2 community is really great if you need help! So much knowledge, and they are always happy to share it :)

I've had plenty of help myself since I started, and I'm sure I'll have plenty more questions to ask in the future. After all, there's always something new to learn ;)
B
34
S
6
G
7
Posts: 494
Reputation: 8,282

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 26 guests